Join to Get Free Linux Server Hacks & cPanel Tips

#1045 Cannot log in to the MySQL server phpMyAdmin error

#1045 Cannot log in to the MySQL server phpMyAdmin error
5 (100%) 3 votes

#1045 Cannot log in to the MySQL server, this was the error I got today on a phpMyAdmin installation inside a cPanel server while trying to access the application.

phpMyAdmin is one of the best tools to handle your MySQL databases and tables inside cPanel servers. However, sometimes we get strange errors while trying to use it.

Today we will explore how to fix #1045 Cannot log in to the MySQL server error.

Fix for #1045 Cannot log in to the MySQL server phpMyAdmin error

Check if your MySQL server is running ok

service mysql status

The expected output maybe this on CentOS 6 / RHEL 6:

root@server.nixcp.com [~]# pidof mysqld
mysqld (pid 23832) is running...

Or this on CentOS / RHEL 7

root@server.nixcp.com [~]# service mysql status

Redirecting to /bin/systemctl status mysql.service
● mysql.service - MySQL Server
Loaded: loaded (/etc/systemd/system/mysql.service; enabled; vendor preset: disabled)
Active: active (running) since mié 2017-01-11 18:44:10 CST; 20h ago
Main PID: 895 (mysqld_safe)
CGroup: /system.slice/mysql.service
├─ 895 /bin/sh /usr/bin/mysqld_safe
└─1467 /usr/sbin/mysqld --basedir=/usr --datadir=/var/lib/mysql --plugin-dir=/usr/lib64/mysql/plugin --log-error=/var/lib/mysql/server2....

ene 11 18:44:10 server.nixcp.com mysqld_safe[895]: Executing: /usr/bin/mysqld_safe
ene 11 18:44:11 server.nixcp.com mysqld_safe[895]: 170111 18:44:11 mysqld_safe Logging to '/var/lib/mysql/server.nixcp.com.err'.
ene 11 18:44:11 server.nixcp.com mysqld_safe[895]: 170111 18:44:11 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql
root@server.nixcp.com [~]#

As you see, it’s working.

Another way to test if MySQL is running is using pidof command:

root@server.nixcp.com [~]# pidof mysqld
1467
root@server.nixcp.com [~]# 

If you see a process ID number like that, then it’s ok.

Try to login to your MySQL console as root

Type this command:

mysql -u root

Expected output:

root@server.nixcp.com [~]# mysql -u root
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 1104836
Server version: 5.5.52-cll MySQL Community Server (GPL)

If you success, then now you know that it doesn’t work on phpMyAdmin, but your MySQL console login is working perfectly.

What do expect if your MySQL is not running?

In that case, you must start MySQL using this command:

/etc/init.d/mysql start 

If your MYSQL is not starting, you will need to troubleshoot why it is not starting as expected.

Check if you have free disk space on your box:

df -ah

You may have run out of available disk space and MySQL will not work as usual when your partitions are full.

You may also ensure /tmp permissions are correctly set to 1777, run this command:

chmod 1777 /tmp -v

After that, try restarting MySQL again:

service mysql restart

If that still shows MySQL failing, then you will have to inspect MySQL logs by tailing this logs:

tail -f /var/log/mysqld.log

or

tail -f /var/lib/mysql/hostname.err

Replace “hostname” with your real server hostname.

For example:

tail -f /var/lib/mysql/server.nixcp.com.err

Another fix for this is trying to reset the cPanel password for the user which is facing the problems, and make sure ‘Allow MySQL password change’ is active when you change the password.

Do you know other ways to fix #1045 Cannot log in to the MySQL server phpMyAdmin error ? Please share your thoughts and solutions with us using the comment for below.