These error occurs when mysql socket is not configured properly. PhpMyAdmin tries to fetch the mysql.sock file from /tmp. By default the mysql.sock file is /var/lib/mysql/mysql.sock. Thus phpMyAdmin won’t be able to fetch the sock file. You can use the following steps to fix the issue.
Locate the socket file of MySQL(mysql.sock).
Normally it would be under the following location:
/var/lib/mysql/mysql.sock
Create a symlink of the file to /tmp
ln -s /var/lib/mysql/mysql.sock /tmp/mysql.sock
Better yet, edit /etc/my.cnf (which won’t exist at first) and add the following four lines:
[client]
socket = /var/mysql/mysql.sock
[mysqld]
socket = /var/mysql/mysql.sock
Be sure to make /var/mysql/ owned by “_mysql” first, so mysql can write its socket there.
This is a good place to put it, because the built-in PHP has been compiled to look for that path.