无法启动mysql服务


10

我无法从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服务mysql restart)。套接字似乎丢失了,所以我寻找了如何创建它的方法,而我发现的所有解决方案都是重启mysql服务...如何解决此错误?


1
仅在服务运行后,套接字才到位,停止后,将其卸下。检查/etc/my.cnf并确保存在datadir,logdir和日志文件目录,并且这些目录可以由mysql用户写入。
Alex Berry

1
尝试使用systemctl restart mysql.service不确定服务是否能够正确处理systemd。
lsmooth

@AlexBerry我没有文件/etc/my.cnf。我应该创建它吗?我应该放什么呢?
Eko 2013年

@lsmooth此命令存在相同错误
Eko

Answers:


14

运行mysqld --help并检查是否报告配置问题

检查登录 /var/log/mysql

直接尝试runnig并检查错误:

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

1
我的配置确实存在问题,缺少文件夹。如果我直接使用您的方法运行它,则会在日志中出现错误:“未知变量'myisam-recover = BACKUP'”,这将导致关机
Eko

3
尝试将其重命名为“ myisam-recover-options = BACKUP”,如果有帮助,请接受答案
Selivanov Pavel
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.