Question

MySQL -Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)

  • Posted September 30, 2014

I currenty have a LAMP, running on Ubuntu 14.04, yesterday everything was fine, but today my MYSQL is not working.

When i try to connect via

mysql -u root -p

I get the error: ERROR 2002 (HY000): Can’t connect to local MySQL server through socket ‘/var/run/mysqld/mysqld.sock’ (2)

the Mysql.err file is completely empty, and have absolute no ideia about what to do.

Subscribe
Share

/etc/init.d/mysqld restart

this work for me!

/etc/init.d/mysql start

worked for me. I am using kali linux. thank you lots.

/etc/init.d/mysql start

worked for me. I am using kali linux. thank you lots.

/etc/init.d/mysql start

worked for me. I am using kali linux. thank you lots.

/etc/init.d/mysql start

worked for me. I am using kali linux. thank you lots.

/etc/init.d/mysql start

worked for me. I am using kali linux. thank you lots.

I think you didn’t started your database server, start it using

#services mysql start
or 
#/etc/init.d/mysql start

If you are getting a failure message while starting, check the log file (/var/log/syslog), if you found socket connection error message there, then check for correct socket file location #find / -type s, if you found a mysqld.sock file under /var/run/mysqld/ directory, check whether any instances of mysqld running or not #netstat -anpt | grep 3306 or #ps aux | grep mysqld if you found any running process stop it (#kill -9 pid) and remove the socket file. Then try to restart it and if mysql not creating socket file then try start it like

#/usr/sbin/mysqld --defaults-file=/etc/mysql/my.cnf --basedir=/usr --datadir=/var/lib/mysql --pid-file=/var/run/mysqld/mysqld.pid --socket=/var/run/mysqld/mysqld.sock

Also check your my.cnf file (/etc/mysql/my.cnf) and comment the bind-address field, and if you found any skip-network field comment it.

regards, sreejith kb

I think you didn’t started your database server, start it using

#services mysql start
or 
#/etc/init.d/mysql start

If you are getting a failure message while starting, check the log file (/var/log/syslog), if you found socket connection error message there, then check for correct socket file location #find / -type s, if you found a mysqld.sock file under /var/run/mysqld/ directory, check whether any instances of mysqld running or not #netstat -anpt | grep 3306 or #ps aux | grep mysqld if you found any running process stop it (#kill -9 pid) and remove the socket file. Then try to restart it and if mysql not creating socket file then try start it like

#/usr/sbin/mysqld --defaults-file=/etc/mysql/my.cnf --basedir=/usr --datadir=/var/lib/mysql --pid-file=/var/run/mysqld/mysqld.pid --socket=/var/run/mysqld/mysqld.sock

Also check your my.cnf file (/etc/mysql/my.cnf) and comment the bind-address field, and if you found any skip-network field comment it.

regards, sreejith kb

I think you didn’t started your database server, start it using

#services mysql start
or 
#/etc/init.d/mysql start

If you are getting a failure message while starting, check the log file (/var/log/syslog), if you found socket connection error message there, then check for correct socket file location #find / -type s, if you found a mysqld.sock file under /var/run/mysqld/ directory, check whether any instances of mysqld running or not #netstat -anpt | grep 3306 or #ps aux | grep mysqld if you found any running process stop it (#kill -9 pid) and remove the socket file. Then try to restart it and if mysql not creating socket file then try start it like

#/usr/sbin/mysqld --defaults-file=/etc/mysql/my.cnf --basedir=/usr --datadir=/var/lib/mysql --pid-file=/var/run/mysqld/mysqld.pid --socket=/var/run/mysqld/mysqld.sock

Also check your my.cnf file (/etc/mysql/my.cnf) and comment the bind-address field, and if you found any skip-network field comment it.

regards, sreejith kb

I think you didn’t started your database server, start it using

#services mysql start
or 
#/etc/init.d/mysql start

If you are getting a failure message while starting, check the log file (/var/log/syslog), if you found socket connection error message there, then check for correct socket file location #find / -type s, if you found a mysqld.sock file under /var/run/mysqld/ directory, check whether any instances of mysqld running or not #netstat -anpt | grep 3306 or #ps aux | grep mysqld if you found any running process stop it (#kill -9 pid) and remove the socket file. Then try to restart it and if mysql not creating socket file then try start it like

#/usr/sbin/mysqld --defaults-file=/etc/mysql/my.cnf --basedir=/usr --datadir=/var/lib/mysql --pid-file=/var/run/mysqld/mysqld.pid --socket=/var/run/mysqld/mysqld.sock

Also check your my.cnf file (/etc/mysql/my.cnf) and comment the bind-address field, and if you found any skip-network field comment it.

regards, sreejith kb


Submit an answer
You can type!ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

If you are creating a droplet from snapshot, then make sure to update the bind-address field with the new ip address.

$sudo nano /etc/mysql/my.cnf

Update the bind-address field with new ip address then run

$sudo service mysql start

If you are creating a droplet from snapshot, then make sure to update the bind-address field with the new ip address.

$sudo nano /etc/mysql/my.cnf

Update the bind-address field with new ip address then run

$sudo service mysql start

If you are creating a droplet from snapshot, then make sure to update the bind-address field with the new ip address.

$sudo nano /etc/mysql/my.cnf

Update the bind-address field with new ip address then run

$sudo service mysql start

If you are creating a droplet from snapshot, then make sure to update the bind-address field with the new ip address.

$sudo nano /etc/mysql/my.cnf

Update the bind-address field with new ip address then run

$sudo service mysql start

If you are creating a droplet from snapshot, then make sure to update the bind-address field with the new ip address.

$sudo nano /etc/mysql/my.cnf

Update the bind-address field with new ip address then run

$sudo service mysql start

If you are creating a droplet from snapshot, then make sure to update the bind-address field with the new ip address.

$sudo nano /etc/mysql/my.cnf

Update the bind-address field with new ip address then run

$sudo service mysql start

I had the same problem and i solved it restarting the mysql server.

sudo service mysql restart

I had the same problem and i solved it restarting the mysql server.

sudo service mysql restart

I had the same problem and i solved it restarting the mysql server.

sudo service mysql restart

I had the same problem and i solved it restarting the mysql server.

sudo service mysql restart