Why do I get "Access denied for user 'root'@'myhostname" when connecting to my database in PHP?
I have set up an Apache server on mandriva linux 2010.1. But the problem is whenever I'm trying to connect with the database, it's giving me the 开发者_开发百科following error:
Error:Database error: SQLSTATE[28000] [1045] Access denied for user 'root'@'myhostname' (using password: YES)
Normally for a web application, you shouldn't connect to the database as root
. However you tagged your post as [phpmyadmin]
so I assume your issue is with, well, phpMyAdmin, in which case you might be connecting as root.
If this is the case, I see that you mentioned myhostname
in your error message. Have you tried connecting to localhost
instead? Sometimes the MySQL root
user cannot connect from remote hosts.
you need to set some configuration variables for phpmyadmin to work: http://www.phpmyadmin.net/documentation/Documentation.html#config
GRANT ALL PRIVILEGES ON *.* TO monty@localhost
IDENTIFIED BY 'indian' WITH GRANT OPTION;
Replace your username and password and execute it in your phpmyadmin by selecting your database.
Take a look at "5.4.7. Causes of Access-Denied Errors" in the MySQL online documentation and Using authentication modes" in the PHPMyAdmin documentation.
精彩评论