您的位置 首页 > 数码极客

【mysql重启】解决Centos7重启导致mysql服务启动失败问题

错误信息如下:

[root @ localhost ~]# MySQL-uroot-p

Enter password:

error 2002(hy 000): can ' t connect to local MySQL server through socket '/var/lib/MySQL;(111)

[root@localhost ~]# /etc start

starting mysqld(via system CTL): job for my failed because the control process exited with error code . see ' system CTL status

[失败]

错误的原因是:

启动MySQL服务时无法创建PID文件。

解决办法:

创建了/var/run/mysqld/目录,重启MySQL服务

实际步骤:

1. 创建相关目录,命令如下:

mkdir -p /var/run/mysqld/

2.再次尝试启动:

/etc start

[root@localhost ~]# /etc start

Starting mysqld (via systemctl): Job for my failed because the control process exited with error code. See "systemctl status my" and "journalctl -xe" for details.

[失败]

依旧启动失败,问题原因在于 /var/run/mysqld/的属主和属组还是root,mysql并不能在其中创建文件,后修改该目录的属主和属组,启动OK。

解决步骤:

1.查看相关目录所属权限

ls -ld /var/run/mysqld/

[root@localhost ~]# ls -ld /var/run/mysqld/

drwxr-xr-x. 2 root root 40 7月 4 19:01 /var/run/mysqld/

2.修改权限:

chown my /var/run/mysqld/

[root@localhost ~]# chown my /var/run/mysqld/

3.最后再次尝试重新启动

[root@localhost ~]# /etc start

Starting mysqld (via systemctl): [ 确定 ]

至此,最后启动成功!!

关于作者: admin

无忧经验小编鲁达,内容侵删请Email至wohenlihai#qq.com(#改为@)

热门推荐