解决MySQL因不能创建 PID 导致无法启动的方法
更新时间:2017年06月26日 10:01:41 作者:Carey
这篇文章主要给大家介绍了关于解决MySQL因不能创建 PID 导致无法启动的方法,文中通过示例代码介绍的非常详细,对大家具有一定的参考学习价值,需要的朋友们下面跟着小编一起来学习学习吧。
问题描述
MySQL 启动报错信息如下:
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]
根据提示,使用 systemctl status mysqld.service
和 journalctl -xe
查看服务启动失败的原因。
[root@ ~]# systemctl status mysqld.servicemysqld.service - SYSV: MySQL database server.Loaded: loaded (/etc/rc.d/init.d/mysqld)Active: failed (Result: exit-code) since Wed 2016-01-20 18:26:57 CST; 40s agoDocs: man:systemd-sysv-generator(8)Process: 2979 ExecStart=/etc/rc.d/init.d/mysqld start (code=exited, status=1/FAILURE)Jan 20 18:26:56 spark01 systemd[1]: Starting SYSV: MySQL database server….Jan 20 18:26:57 spark01 mysqld[2979]: MySQL Daemon failed to start.Jan 20 18:26:57 spark01 mysqld[2979]: Starting mysqld: [FAILED]Jan 20 18:26:57 spark01 systemd[1]: mysqld.service: control process exited, code=exited status=1Jan 20 18:26:57 spark01 systemd[1]: Failed to start SYSV: MySQL database server..Jan 20 18:26:57 spark01 systemd[1]: Unit mysqld.service entered failed state.Jan 20 18:26:57 spark01 systemd[1]: mysqld.service failed.[root@ ~]# journalctl -xeUnit session-2.scope has begun starting up.Jan 20 18:26:48 spark01 sshd[2916]: pam_unix(sshd:session): session opened for user spark by (uid=0)Jan 20 18:26:52 spark01 su[2944]: (to root) spark on pts/1Jan 20 18:26:52 spark01 su[2944]: pam_unix(su-l:session): session opened for user root by spark(uid=1000)Jan 20 18:26:56 spark01 polkitd[909]: Registered Authentication Agent for unix-process:2974:117137 (system bus name :1.25Jan 20 18:26:56 spark01 systemd[1]: Starting SYSV: MySQL database server….— Subject: Unit mysqld.service has begun start-up— Defined-By: systemd— Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel—— Unit mysqld.service has begun starting up.Jan 20 18:26:57 spark01 mysqld[2979]: MySQL Daemon failed to start.Jan 20 18:26:57 spark01 mysqld[2979]: Starting mysqld: [FAILED]Jan 20 18:26:57 spark01 systemd[1]: mysqld.service: control process exited, code=exited status=1Jan 20 18:26:57 spark01 systemd[1]: Failed to start SYSV: MySQL database server..— Subject: Unit mysqld.service has failed— Defined-By: systemd— Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel—— Unit mysqld.service has failed.—— The result is failed.Jan 20 18:26:57 spark01 systemd[1]: Unit mysqld.service entered failed state.Jan 20 18:26:57 spark01 systemd[1]: mysqld.service failed.Jan 20 18:26:57 spark01 polkitd[909]: Unregistered Authentication Agent for unix-process:2974:117137 (system bus name :1.
这些信息并不能提供服务启动失败的真正原因。
查看 MySQL 的告警日志:
2016-01-20T10:00:19.935771Z 0 [ERROR] /usr/sbin/mysqld: Can't create/write to file ‘/var/run/mysqld/mysqld.pid' (Errcode: 2 - No such file or directory)2016-01-20T10:00:19.935795Z 0 [ERROR] Can't start server: can't create PID file: No such file or directory160120 18:00:20 mysqld_safe mysqld from pid file /var/run/mysqld/mysqld.pid ended
解决办法
MySQL 服务在启动的时候,不能创建 pid 文件。
在终端看一下该目录是否存在,如果不存在,手动创建:
[root@ ~]# mkdir -p /var/run/mysqld/
再次尝试启动 MySQL 服务,报错如下:
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]
查看 MySQL 的告警日志:
2016-01-20T10:28:37.183387Z 0 [ERROR] /usr/sbin/mysqld: Can't create/write to file ‘/var/run/mysqld/mysqld.pid' (Errcode: 13 - Permission denied)2016-01-20T10:28:37.183431Z 0 [ERROR] Can't start server: can't create PID file: Permission denied160120 18:28:37 mysqld_safe mysqld from pid file /var/run/mysqld/mysqld.pid ended160120 18:32:06 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql
权限不正确,/var/run/mysqld/ 的属主和属组还是 root,MySQL 并不能在其中创建文件后修改该目录的属主和属组
[root@ ~]# ls -ld /var/run/mysqld/drwxr-xr-x 2 root root 40 Jan 20 18:28 /var/run/mysqld/ [root@ ~]# chown mysql.mysql /var/run/mysqld/ [root@ ~]# /etc/init.d/mysqld startStarting mysqld (via systemctl): [ OK ]
总结
以上就是这篇文章的全部内容了,希望本文的内容对大家的学习或者工作能带来一定的帮助,如果有疑问大家可以留言交流,谢谢大家对脚本之家的支持。
您可能感兴趣的文章:
- Python聊天室带界面实现的示例代码(tkinter,Mysql,Treading,socket)
- ERROR 2002 (HY000): Can''t connect to local MySQL server through socket ''/tmp/mysql.sock''
- Can''t connect to local MySQL through socket ''/tmp/mysql.sock''解决方法
- java+jdbc+mysql+socket搭建局域网聊天室
- Java Socket+mysql实现简易文件上传器的代码
- mysql socket文件作用详解
- MySQL错误ERROR 2002 (HY000): Can''t connect to local MySQL server through socket
- MySQL HandlerSocket插件安装配置教程
- 深度解析MySQL启动时报“The server quit without updating PID file”错误的原因
- mysql启动报错MySQL server PID file could not be found
- Mysql挂掉后无法重启报pid文件丢失的解决方法
- MySQL下PID文件丢失的相关错误的解决方法
- mysql:Can''t start server: can''t create PID file: No space left on device
- MySQL提示:The server quit without updating PID file问题的解决办法
- linux mysql 报错:MYSQL:The server quit without updating PID file
- Starting MySQL.Manager of pid-file quit without updating file.[FAILED]的解决方法
- 详解MySQL中的pid与socket
相关文章
通过mysql show processlist 命令检查mysql锁的方法
show processlist 命令非常实用,有时候mysql经常跑到50%以上或更多,就需要用这个命令看哪个sql语句占用资源比较多,就知道哪个网站的程序问题了。2010-03-03
最新评论