Linux的MySQL服务启动失败:Failed to start SYSV: MySQL databas....

报错

[root@localhost ~]# mysql -uroot -p
Enter password: 
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (111)
[root@localhost ~]# service mysqld start
Starting mysqld (via systemctl):  Job for mysqld.service failed because the control process exited with error code. See "systemctl status mysqld.service" and "journalctl -xe" for details.
                                                           [FAILED]
[root@localhost ~]# systemctl status mysqld.service
● mysqld.service - SYSV: MySQL database server.
   Loaded: loaded (/etc/rc.d/init.d/mysqld)
   Active: failed (Result: exit-code) since Mon 2021-04-19 04:42:17 EDT; 40s ago
     Docs: man:systemd-sysv-generator(8)
  Process: 2896 ExecStart=/etc/rc.d/init.d/mysqld start (code=exited, status=1/FAILURE)

Apr 19 04:42:16 localhost.localdomain systemd[1]: Starting SYSV: MySQL database serve....
Apr 19 04:42:17 localhost.localdomain mysqld[2896]: MySQL Daemon failed to start.
Apr 19 04:42:17 localhost.localdomain mysqld[2896]: Starting mysqld:  [FAILED]
Apr 19 04:42:17 localhost.localdomain systemd[1]: mysqld.service: control process exi...1
Apr 19 04:42:17 localhost.localdomain systemd[1]: Failed to start SYSV: MySQL databas....
Apr 19 04:42:17 localhost.localdomain systemd[1]: Unit mysqld.service entered failed ....
Apr 19 04:42:17 localhost.localdomain systemd[1]: mysqld.service failed.
Hint: Some lines were ellipsized, use -l to show in full.

解决

建立缺少的目录,和修改权限
[root@localhost ~]# mkdir -p /var/run/mysqld
[root@localhost ~]# service mysqld start
Starting mysqld (via systemctl):  Job for mysqld.service failed because the control process exited with error code. See "systemctl status mysqld.service" and "journalctl -xe" for details.
                                                           [FAILED]
[root@localhost ~]# systemctl start mysqld
Job for mysqld.service failed because the control process exited with error code. See "systemctl status mysqld.service" and "journalctl -xe" for details.
[root@localhost ~]# chown mysql.mysql /var/run//mysqld/
[root@localhost ~]# systemctl start mysqld
[root@localhost ~]# mysql -uroot -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 3
Server version: 5.7.28 MySQL Community Server (GPL)

Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql>

版权声明:本文为qq_43416157原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。