Unable to establish a connection with ‘/var/run/mysqld/mysqld.sock’

To uninstall mysql, I executed the given commands. Similarly, to install mysql 5.5, I followed the given commands. It is recommended to verify the socket location in my.cnf file to ensure it matches the default and is not commented out. In case of socket mapping, there is a query regarding accessing the mysql server on the host from the docker container.


As a first-time poster, I hope to provide all the essential details without missing anything important. Any suggestions are welcome as I am struggling to come up with ideas.

My owncloud was operational on Raspbian Jessie, which is essentially Debian. However, it suddenly stopped functioning. Upon checking, I found that the nginx error was related to php5-fpm. Further research revealed the same error.

exception 'DoctrineDBALDBALException' with message 'Failed to connect to the database: An exception occured in driver: SQLSTATE[HY000] [2002] Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)' in /var/www/owncloud/lib/private/db/connection.php:54

There seems to be a mysql error as


is empty.

After reviewing the aforementioned posts 1 and 2, I made an attempt.

sudo find / -type s

resulting in this output:

find: `/proc/30933/task/30933/fd/5': No such file or directory
find: `/proc/30933/task/30933/fdinfo/5': No such file or directory
find: `/proc/30933/fd/5': No such file or directory
find: `/proc/30933/fdinfo/5': No such file or directory

On one hand,


involves the appearance of mysqld and mysqld_safe. On the other hand, the latest versions of mysql-client,
, and php5-mysql are installed and updated in these processes.

I also had a look at


The socket for
is displayed in both /var/run/ directories.


mentioned here does not exist.

Furthermore, it appears that my inability to connect to MySQL persists.

mysql -u user -p

The outcome is also the Error 2002, at the very minimum.

After attempting several methods, I decided to stop and start the mysql service, which produced the subsequent result.

systemctl status mysql.service
mysql.service - LSB: Start and stop the mysql database server daemon
Loaded: loaded (/etc/init.d/mysql)
Active: failed (Result: exit-code) since So 2016-04-10 11:54:23 CEST; 23s ago
Process: 9777 ExecStop=/etc/init.d/mysql stop (code=exited, status=0/SUCCESS)
Process: 12878 ExecStart=/etc/init.d/mysql start (code=exited, status=1/FAILURE)

I am unsure of the current situation and when the issue began, possibly due to recent updates. To ensure accuracy, I repeated all the steps while composing this message. Although I briefly saw my owncloud instance in the browser, it disappeared quickly. Any assistance or clues would be greatly appreciated.

Thank you very much!!!

Solution 1:

Encountered a problem while trying to establish a connection to ‘
‘, as the mysql service was not launched post installation. However, the issue was resolved upon running a command.

systemctl start mysql.service
mysql -u root -p

Solution 2:

1.Activate log in .my.cnf

 log        = /var/log/mysql/mysql.log

Debian has made an improvement by directing error logging to syslog.

You can find here the queries that have a significantly extended duration.

log_slow_queries    = /var/log/mysql/mysql-slow.log
long_query_time = 2

  1. $ ls -l /var/run/ | grep mysqld

  2. $ ps -ef |grep mysql

  3. tail -f /var/log/mysql/mysql.log
  4. re
    start mysql
  5. You may opt to remove the socket and then proceed to restart MySQL.

Frequently Asked Questions