Saturday, July 25, 2009

How do I create user accounts for mySQL using php?

I need to add user accounts to mySQL using php.





I have to following code but am unsure how to execute it:


GRANT ALL PRIVILEGES ON *.* TO 'testuser'@'localhost' IDENTIFIED BY 'testpass' WITH GRANT OPTION





When I run this through phpmyadmin I get:


Access denied for user 'craig'@'localhost' (using password: YES)





'craig' is not a mySQL user account, it is my web host login


Is that why I get the error?





How do I run this from php?


Can I execute it with mysql_query()? or is there something else?
How do I create user accounts for mySQL using php?
Hello,





That is because your webhost company does not allow you to Add a new user since your current user 'craig' does not have enough priveleges.





Basically, many shared webhosting companies are like that. They usually have a web admin panel such as CPanel or anything similar, that you add MySQL users there! Then you can login using that.





So lets repeat:


I assume you havn't created a Database User yet using your webhosting service. (go on their administration page, and check MySQL section and create user from there)





That is not the reason why your getting that error. You already logged in PHPMyAdmin :) so you do have a MySQL user which is active. I assume.





So technically speaking, you have to use their tool to create users, and that current user that your using has no permission to create a new user.





Good Luck


No comments:

Post a Comment