I have problems with using 'GRANT'. My aim is to create a database, then assign permissions for the new user:
// set your infomation.
// connect to the mysql database server.
$link_id = mysql_connect ($dbhost, $dbusername, $dbuserpass);
echo "success in database connection.";
// create the database.
if (!mysql_query("CREATE DATABASE $dbname")) die(mysql_error());
echo "success in database creation.";
//grant user rights.
if (!mysql_query("grant all on $dbname.* to $newuser identified by $newuserpasswd")) die(mysql_error());
echo "success in grant creation.";
The database is created Ok, but fails on the 'Grant' sections. The error message reads:
You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near 'abc123' at line 1
Any help appreciated.