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

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.

Accessing PhpMyAdmin without cPanel login?

This article will help you to access databases of cPanel users’ without accessing the cPanel account.

Consider the scenario, you’ve a cPanel account and you want to share the details of a database (DB) with one of your we site developers and  actually you do not want to share the cPanel credentials. 

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

Solution

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
23832
# netstat -plan | grep :3306
tcp        0      0 0.0.0.0:3306                0.0.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 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?

Update: Just reviewed the post. It’s a very old post and for cPanel servers. No sure if it correct for latest WHM/cPanel servers.

Post navigation

Heba Habeeb

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

11 thoughts on “[Solved] PHPMyAdmin Error; #1045 Cannot log in to the MySQL server

  1. 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 127.0.0.1 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 *