I'm familiar with creating new databases with PHP, but can I create new users as well?
I scoped out php.net but couldn't find anything relevant. Google wasn't much help either
I know it's possible because all the popular web hosting backpanels let you do it (cpanel, plesk..). The question is what are they doing it with? Are they using a web language or executing batch files? What would be the simplest way to dynamically create new MySQL user accounts?
Thanks in advance.
- John
Creating new MySQL users with PHP?
Moderator: General Moderators
Thanks feyd, I do have access to the mysql database because it's my server.
Just to clarify what you suggested, I will be able to add users by inserting new values into a "user" table in the "mysql" database?
edit: I am looking at it now, and the passwords seem to be encrypted. Is that md5 or SHA-1 encryption?
Just to clarify what you suggested, I will be able to add users by inserting new values into a "user" table in the "mysql" database?
edit: I am looking at it now, and the passwords seem to be encrypted. Is that md5 or SHA-1 encryption?
http://dev.mysql.com/doc/mysql/en/grant.htmlI'm familiar with creating new databases with PHP, but can I create new users as well?
Code: Select all
mysql_query("GRANT ALL ON *.* TO '" . mysql_real_escape_string($user) . "' IDENTIFIED BY '" . mysql_real_escape_string($password) . "'");