10

I can't restart my mysql service from my ubuntu server. Here is the error :

● mysql.service - LSB: Start and stop the mysql database server daemon
Loaded: loaded (/etc/init.d/mysql; bad; vendor preset: enabled)   
Active: failed (Result: exit-code) since mer. 2016-06-08 17:31:06 CEST; 54s ago
Docs: man:systemd-sysv-generator(8)   Process: 4087 ExecStart=/etc/init.d/mysql start (code=exited, status=1/FAILURE)

juin 08 17:31:06 SRV-OVH-GIC03-V /etc/init.d/mysql[4569]: 0 processes alive and '/usr/bin/mysqladmin --defaults-file=/etc/mysql/debian.cnf ping' resulted in
juin 08 17:31:06 SRV-OVH-GIC03-V /etc/init.d/mysql[4569]: [61B blob data]
juin 08 17:31:06 SRV-OVH-GIC03-V /etc/init.d/mysql[4569]: error: 'Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2 "No such file or directory")'
juin 08 17:31:06 SRV-OVH-GIC03-V /etc/init.d/mysql[4569]: Check that mysqld is running and that the socket: '/var/run/mysqld/mysqld.sock' exists!
juin 08 17:31:06 SRV-OVH-GIC03-V /etc/init.d/mysql[4569]:
juin 08 17:31:06 SRV-OVH-GIC03-V mysql[4087]:    ...fail!
juin 08 17:31:06 SRV-OVH-GIC03-V systemd[1]: mysql.service: Control process exited, code=exited status=1
juin 08 17:31:06 SRV-OVH-GIC03-V systemd[1]: Failed to start LSB: Start and stop the mysql database server daemon.
juin 08 17:31:06 SRV-OVH-GIC03-V systemd[1]: mysql.service: Unit entered failed state.
juin 08 17:31:06 SRV-OVH-GIC03-V systemd[1]: mysql.service: Failed with result 'exit-code'.

I've tried to restart the mysql service (sudo service mysql restart). The socket seem to be missing, so I looked for how to create it and all the solutions I find is to restart the mysql service... How can I fix this error?

4
  • 1
    The socket is only in place once the service is running, when stopped the socket is removed. Check /etc/my.cnf and ensure the datadir, logdir and log file directorys are present and can be written to by the mysql user. – Alex Berry Jun 8 '16 at 15:49
  • 1
    Try using systemctl restart mysql.service not sure if service correctly handles systemd. – lsmooth Jun 8 '16 at 16:14
  • @AlexBerry I don't have the file /etc/my.cnf. Should I create it? What should I put in it? – Eko Jun 9 '16 at 7:09
  • @lsmooth Same error with this command – Eko Jun 9 '16 at 7:09
15

Run mysqld --help and check, if it reports any problems with config

Check logs in /var/log/mysql

Try runnig it directly and check errors:

mkdir /var/run/mysqld/
chown mysql: /var/run/mysqld/
mysqld --basedir=/usr --datadir=/var/lib/mysql --user=mysql --socket=/var/run/mysqld/mysqld.sock
2
  • 1
    I had indeed problems with the config, a folder was missing. If I run it directly with your method, I have errors in logs : " unknown variable 'myisam-recover=BACKUP' " which causes to shutdown – Eko Jun 9 '16 at 7:06
  • 3
    Try renaming it to 'myisam-recover-options=BACKUP' And please accept answer, if it helps – Selivanov Pavel Jun 9 '16 at 7:11

Not the answer you're looking for? Browse other questions tagged or ask your own question.