Unable to connect MySQL server 5.7.22...

July 6, 2018 636 views
MySQL Ubuntu 16.04

I work on cloud Ubuntu 16.04 and configure Asterisk server from scratch, but unable to resolve MySQL server to connect to local host i tried different solutions but unable to resolve issue

ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock'

change my.cnf files reconfigure it again but still got an error...

1 Answer


That error means the file /var/run/mysqld/mysqld.sock doesn't exists, if you didn't install mysql-server, then the file would not exist. But if the mysql-server is already installed and is running, then you need to check the config files.

The config files are:


In /etc/my.cnf, the socket file config may be /tmp/mysql.sock and in /etc/mysql/my.cnf the socket file config may be /var/run/mysqld/mysqld.sock. So, remove or rename /etc/mysql/my.cnf, let mysql use /etc/my.cnf, then the problem may solved.

Hope this helps!


Have another answer? Share your knowledge.