Search code examples
phpmysqlphpmyadminmysql-error-1045

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)


Solution

  • 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.