2

This is my first post here, so I hope I do everything right and don't forget any important info. I'm glad for any hints, because I'm running out of ideas (if I ever had any ;)).

I am (or was) running owncloud on Raspbian Jessie (so I guess basically Debian). Suddenly owncloud stopped working. The nginx error points towards php5-fpm, further searches gave this error:

exception 'Doctrine\DBAL\DBALException' 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

So it looks like a mysql error, and /var/run/mysqld/ is actually empty.

Following these posts 1 and 2, I tried

sudo find / -type s

resulting in this output:

/run/php5-fpm.sock
/run/fail2ban/fail2ban.sock
/run/thd.socket
/run/dhcpcd.unpriv.sock
/run/dhcpcd.sock
/run/dbus/system_bus_socket
/run/avahi-daemon/socket
/run/udev/control
/run/systemd/journal/syslog
/run/systemd/journal/socket
/run/systemd/journal/stdout
/run/systemd/journal/dev-log
/run/systemd/shutdownd
/run/systemd/private
/run/systemd/notify
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

In the processes with top on the other hand, mysqld and mysqld_safe show up. mysql-client, mysql-server and php5-mysql are installed and updated to the latest versions.

I also had a look at

/etc/mysql/my.cnf
/etc/mysql/debian.cnf

both show /var/run/mysqld/mysqld.sock as socket...

/var/lib/mysql/my.cnf

mentioned here does not exist.

Additionally, it seems that I can't connect to mysql through

mysql -u user -p

at least it results in the Error 2002 as well.

Finally, I tried stopping and starting the mysql service. This resulted in the following output of

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)

So I'm kind of lost what is going on, the problem occurs since some updates a few days ago. While writing this post, I went through all the steps again, just to be safe. At one point, I had a short glimpse at my owncloud instance in the browser, but then it was gone again. So I appreciate any help/hints!!!

Thank you very much!!!

Community
  • 1
  • 1
Fo Tastisch
  • 21
  • 1
  • 2

2 Answers2

2

I faced the issue: Can't connect to '/var/run/mysqld/mysqld.sock'. The problem was that mysql service was not started after installation. Once I run the following command, then it worked properly:

systemctl start mysql.service
mysql -u root -p
seb_dom
  • 73
  • 7
0

1.Activate log in .my.cnf

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

Error logging goes to syslog. This is a Debian improvement :)

Here you can see queries with especially long duration

log_slow_queries    = /var/log/mysql/mysql-slow.log
long_query_time = 2
log-queries-not-using-indexes
  1. $ ls -l /var/run/ | grep mysqld
  2. $ ps -ef |grep mysql
  3. tail -f /var/log/mysql/mysql.log
  4. restart mysql
  5. (option) delete socket & restart mysql
PerlDuck
  • 5,342
  • 3
  • 16
  • 35
Ronnin
  • 15
  • 5
  • Hi! thank you for your answer @Ronnin! I've added logging to my.cnf... The `tail` command gives /usr/sbin/mysqld, Version: 5.5.44-0+deb8u1-log ((Raspbian)). started with: Tcp port: 3306 Unix socket: /var/run/mysqld/mysqld.sock Time Id Command Argument Restarting results in the same error as mentioned above with stopping and starting. How would I delete the socket? Sorry if I didn't understand your answer correctly! – Fo Tastisch Apr 10 '16 at 10:57
  • first give here output from 1.,2. – Ronnin Apr 10 '16 at 11:14
  • 1. `drwxr-xr-x 2 mysql root 40 Apr 10 13:18 mysqld` 2. `root 612 1 2 12:07 ? 00:02:00 /bin/sh /usr/bin/mysqld_safe` `mysql 10174 612 47 13:19 ? 00:00:00 /usr/sbin/mysqld --basedir=/usr --datadir=/var/lib/mysql --plugin-dir=/usr/lib/mysql/plugin --user=mysql --log-error=/var/log/mysql/error.log --pid-file=/var/run/mysqld/mysqld.pid --socket=/var/run/mysqld/mysqld.sock --port=3306` `pi 10192 3628 0 13:19 pts/0 00:00:00 grep --color=auto mysql` – Fo Tastisch Apr 10 '16 at 11:18
  • 1. stop mysq (1a. if stop produce error, killall mysql, again make shure that mysql not runinig with 1.,2.................after thaht $rm /var/run/mysqld/mysqld.pid and $ rm /var/run/mysqld/mysqld.sock........read http://www.thegeekstuff.com/2011/12/mysqlcheck/ – Ronnin Apr 10 '16 at 11:26