Is there a way to create a new MySQL database, a new MySQL user and give the new user privileges on the new database all using PHP?
相关问题
- Views base64 encoded blob in HTML with PHP
- Laravel Option Select - Default Issue
- PHP Recursively File Folder Scan Sorted by Modific
- Can php detect if javascript is on or not?
- Using similar_text and strpos together
i will suggest you to use phpmyadmin.
you need to do steps:
that's all see in action on youtube [ click here ]
in case if you want to know more about phpMyadmin go with official
but if there is any special reason to do so with php the here is the sql commend
open PHP myadmin or MySql workbench go to query window then run below query
If you are hosting your project on CPanel, then the
mysql_query
method will not work to create databases, users, and to grant permissions.You have to use the XML Api for CPanel.
Download xmlapi.php from here, or simply search on google for it.
This is what worked for me perfectly.
You could do something like this:
You may look at the MySQL documentation on GRANT and CREATE USER
Yes, as all these actions can be performed by regular SQL queries.
However, I'd refrain from running PHP scripts with database connection from root user.