无法启动mysql服务

无法启动mysql服务

我无法从 ubuntu 服务器重新启动 mysql 服务。错误如下:

● 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'.

我尝试重新启动 mysql 服务 (sudo service mysql restart)。套接字似乎丢失了,所以我寻找如何创建它,而我找到的所有解决方案都是重新启动 mysql 服务...我该如何修复此错误?

答案1

运行mysqld --help并检查,是否报告配置存在任何问题

检查日志/var/log/mysql

尝试直接运行它并检查错误:

mkdir /var/run/mysqld/
chown mysql: /var/run/mysqld/
mysqld --basedir=/usr --datadir=/var/lib/mysql --user=mysql --socket=/var/run/mysqld/mysqld.sock

相关内容