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

Sandro_V picture Sandro_V · Sep 8, 2016 · Viewed 7.8k times · Source

I have a Ubuntu 14.04. server with LAMP installed where an Owncloud is running. I tried to install paperwork which didn't work out but thats not the problem.

After restarting my server I tried to access my owncloud again but I am facing an internal server error. See following picture. Owncloud error

I looked in the log /var/log/apache2/error.log and theres following phrase:

Lost connection to MySQL server during query' in ...

I tried to restart the mysql service but this error appears:

stop: Unknown instance:
start: Job failed to start

Then I tried to login to mysql with mysql -u root -p and follorwing error appears:

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

I've looked for the sockets on the machine with find / -type s and the socket was there: /run/mysqld/ . I created a symbolic link and pasted it to /var/run/mysqld/mysqld.sock

Unfortnutely nothing worked. After restarting again I can't find the socket anymore the output of find / -type s is:

/dev/log
/run/php5-fpm.sock
/run/udev/control
find: `/proc/977/task/977/fd/5': No such file or directory
find: `/proc/977/task/977/fdinfo/5': No such file or directory
find: `/proc/977/fd/5': No such file or directory
find: `/proc/977/fdinfo/5': No such file or directory

Update

I've reinstalled the server so problem is over :D

Answer

akhisyabab picture akhisyabab · Jan 28, 2017

If you install lampp server, run mysql first

sudo /opt/lampp/lampp startmysql

Then make "mysqld" directory in /var/run

cd /var/run
sudo mkdir mysqld

Link your mysql from lampp to /var/run/mysqld

sudo ln -s /opt/lampp/var/mysql/mysql.sock /var/run/mysqld/mysqld.sock

run mysql -u root -p . hope may help you