[Solved] PHPMyAdmin Error; #1045 Cannot log in to the MySQL server

PhpMyAdmin is a free and open source tool written in PHP intended to handle the administration of MySQL with the use of a web browser. It can perform various tasks such as creating, modifying or deleting databases, tables, fields or rows; executing SQL statements; or managing users and permissions.

This is an error that I received while accessing PHPMyAdmin via cPanel. Please see the error details below:

# 1045 Cannot log in to the MySQL server


1. Check MySQL service is running. You can check this by running the following commands:

# /etc/init.d/mysqld status
# pidof mysqld
# netstat -plan | grep :3306

Expected output:

# /etc/init.d/mysqld status
mysqld (pid 23832) is running...
#pidof mysqld
# netstat -plan | grep :3306
tcp        0      0      *                   LISTEN      23832/mysqld 

If you are getting the expected output, then try to log in the MySQL prompt by running

# mysql -u root -p

If you are getting the expected output and also you are able to log into the MySQL prompt then we can conclude that your MySQL server is up and running.

Special Case:

If not, then your MySQL service is stopped for any reason.
In that case, you can try running

#/etc/init.d/mysqld start 

Even after starting MySQL, if it’s not started then you need to investigate the root cause why the MySQL service is down. For an initial testing, you can check

#df -h
#free -m

Also, check the permission of /tmp and see if you can touch a file in /tmp. If all this cases are fine, then you need to check the MySQL logs in the file /var/lib/mysql/hostname.err or you can check in /var/log/mysqld.log .

In this way you can troubleshoot why the MySQL service is down.

If your MySQL server is up and again you are receiving the error as #1045 Cannot log in to the MySQL server then, you can continue reading this.

2. Reset the cPanel password for the user that you are facing this problem. Make sure that “Allow MySQL password change” has been enabled while you are changing the password.

That’s it!!!

How to access PhpMyAdmin without cpanel password?

Heba Habeeb

Working as a Linux Server Admin, Infopark, Cochin, Kerala.

You may also like...

8 Responses

  1. Amigo says:

    Restablecer contraseña mysql del servidor debería funcionar si ninguna de las anteriores trabajó

  2. raj says:

    thanks for the solution.. i was fed up by serching for this answer… thanks alot

  3. Theresa Leona Divino says:

    i cant understand this, where do i type the /etc…. ? in the cmd? in what directory?

  4. okey says:

    Please am still having that error. After installing my wampserver, it could not turn green, i was adviced to change the port no to port 7080 and listen since the default port was in use by another program, i did it and it turned green but the problem now is that i cant login into the admin page of mysql as i keep getting error “cannot log in to the mysql” pls i hv tried all i could to no avail.

Leave a Reply

Your email address will not be published. Required fields are marked *