Create new database with UAPI functions.
Hi,
I am trying to create a MySQL database and set a current database user to the database.
The PHP code is written as below;
$site = "http://[cpanel_user]:[cpanel_password]@localhost:2082/execute/Mysql/";
$result = file_get_contents("{$site}create_database?name=zubair_test");
$result .= file_get_contents("{$site}set_privileges_on_database?user=zubair_admin&database=zubair_test&privileges=ALL%20PRIVILEGES");
print $result;
Now the database is being created fine with no errors, and it is mapped to the correct CPANEL user.
The issue I am having is setting a current database user to the newly created database. I am receiving the following error response.
{"errors":["(XID kamdnm) Database Error: There is no such grant defined for user 'zubair_admin' on host 'localhost'">,"status":0,"data":null,"messages":null,"metadata":{}}
Am I handling this the correct way to add a user to the newly created database? Perhaps could be a permissions issue with the current connection to MySQL? (The database user 'zubair_admin' I am trying to set to the database is the user I am connecting with).
Any advice or solutions will be much appreciated.
Thanks,
Zubair.
-
Hello, Could you verify which version of cPanel is installed on this system? EX: cat /usr/local/cpanel/version
Thank you.0 -
Hi, The version installed is 11.62.0.15 Thanks, Zubair 0 -
{"errors":["(XID kamdnm) Database Error: There is no such grant defined for user 'zubair_admin' on host 'localhost'">,"status":0,"data":null,"messages":null,"metadata":{}}
Hello, Could you verify how you are adding the database user? Can you reproduce the issue with newly created database users? The following document is helpful if you have made direct changes to a MySQL user's grants in the past: The dbstoregrants Script - Documentation - cPanel Documentation Thank you.0
Please sign in to leave a comment.
Comments
3 comments