Fiko Borizqy
Fiko Borizqy

Follow

Fiko Borizqy

Follow

"Can't Connect To Local MySQL Server Through Socket '/Var/Run/Mysqld/Mysqld.Sock' (2)" on Docker ?

Fiko Borizqy's photo
Fiko Borizqy
·Oct 13, 2019·

1 min read

"Can't Connect To Local MySQL Server Through Socket '/Var/Run/Mysqld/Mysqld.Sock' (2)" on Docker ?

Do you face an issue whereas you can't connect to MySQL? Try to check domysqld.sock and mysqld.pid exist or not. If not, inside the docker terminal, run these commands :

sudo touch /var/run/mysqld/mysqld.sock
sudo touch /var/run/mysqld/mysqld.pid
sudo chown -R mysql:mysql /var/run/mysqld/mysqld.sock
sudo chown -R mysql:mysql /var/run/mysqld/mysqld.pid
sudo chmod -R 644 /var/run/mysqld/mysqld.sock

Then, restart mysql service :

sudo service mysql restart

Still, if your mysql can’t connect to mysql. Run this method and restart the service of mysql (maybe you also need to restart the container if still can’t connect to mysql) :

sudo chown -R mysql:mysql /var/lib/mysql /var/run/mysqld
 
Share this