2010-10-19 34 views
-2

什麼是在PHP執行這個語句的語法PAGE-如何從PHP內部授予MySQL權限?

grant file on *.* to [email protected] identified by 'kentest1'; 
+3

你是什麼意思?你想知道如何執行mySQL語句嗎? – 2010-10-19 14:25:30

+1

我相信如此,爲了節省他/她的谷歌搜索 – 2010-10-19 14:36:54

回答

1

檢查[MySQL的?]數據庫供應商的文檔 - 因爲這是一個DBMS的語句,而不是PHP。我會從這裏開始:http://php.net/manual/en/function.mysql-connect.php

編輯:爲了澄清,假設你得到你的連接工作,這將是爲在呼叫你的包裹查詢mysql_query()一樣簡單。例如:

mysql_connect(...); 
mysql_select_db(...); 
mysql_query("grant file on *.* to [email protected] identified by 'kentest1';"); 
0

首先,你檢查的mysql_connect的用戶,是根?此用戶必須有權授予。

0

下面是一些基本的代碼,會爲很多的MySQL查詢工作,包括GRANT只要用戶權限的情況可以這樣做:

// Credential variables, separated so we can reuse them later 
$host = "localhost"; 
$user = "user"; 
$pass = "123456notsecure"; 
$db = "database_to_use"; 

// Set up the query we're going to run 
$query_to_run = "QUERY TO RUN"; 
// Make the MySQL connection 
$mysql_connection = mysql_connect($host, $user, $pass); 
// Select the database to use 
mysql_select_db($db) or die(mysql_error()); 
// Run the query 
$result_of_query = mysql_query($query_to_run) or die('Running the query failed: ' . mysql_error()); 
// Close the MySQL connection 
mysql_close($mysql_connection);