Skip to main content

Command Palette

Search for a command to run...

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

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

I wrote these tutorials for myself in future when I forget for the next steps.

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

More from this blog

F

Fiko Borizqy (Bestafiko)

51 posts

I wrote these tutorials for myself in future when I forget for the next steps.