Linux MySQL PID 丢失处理
昨天重启了一下Linux服务器的MySQL服务,系统提示ERROR! MySQL server PID file could not be found!
1 .查看mysql日志
[root@fonphxion ~]# less /data/mysql/fonphxion.err
2017-12-12 09:28:15 15704 [Note] InnoDB: Check that you do not already have another mysqld process using the same InnoDB data or log files.
系统提示并没有另一个mysqld进程使用同样的InnoDB data或log files.因此决定查看一下进程
2 .查看进程
[root@fonphxion ~]# ps aux |grep mysql
root 15328 0.0 0.0 113268 1596 pts/2 S 09:26 0:00 /bin/sh /usr/local/mysql/bin/mysqld_safe --datadir=/data/mysql --pid-file=/data/mysql/susanlinux.pid
mysql 15489 0.0 24.9 1300884 467736 pts/2 Sl 09:26 0:00 /usr/local/mysql/bin/mysqld --basedir=/usr/local/mysql --datadir=/data/mysql --plugin-dir=/usr/local/mysql/lib/plugin --user=mysql --log-error=/data/mysql/fonphxion.err --pid-file=/data/mysql/susanlinux.pid --socket=/tmp/mysql.sock
root 15739 0.0 0.0 112664 968 pts/2 R+ 09:42 0:00 grep --color=auto mysql
通过进程,我们发现pid-file=/data/mysql/susanlinux.pid,而我们的用户名是fonphxion,因此知道错误的原因是Linux server服务器计算机名称被修改导致。那如果我们不想把计算机名称修改回去改怎么处理呢。
3 .解决方案
- pid文件名称修改
mv /data/mysql/susanlinux.pid /data/mysql/fonphxion.pid #计算机名.pid
- 修改MySQL的my.cnf文件,添加pid-file = /data/mysql/fonphxion.pid 注意"="号两边的空格
- killall mysql进程,因为名称更改,建议先杀死所有原有进程,否则可能会导致启动失败
- /etc/init.d/mysqld restart 重启mysql服务(因为笔者将mysql启动文件放在/etc/init.d目录内并命名为mysqld)。你也可以通过systemctl restart mysql重启。
[root@fonphxion mysql]# /etc/init.d/mysqld restart Shutting down MySQL.. SUCCESS! Starting MySQL. SUCCESS!
进程也恢复正常
[root@fonphxion mysql]# ps aux | grep mysql root 16988 0.0 0.0 115388 1672 ? S 09:56 0:00 /bin/sh /usr/local/mysql/bin/mysqld_safe --datadir=/data/mysql --pid-file=/data/mysql/fonphxion.pid mysql 17150 0.3 24.5 1300884 460872 ? Sl 09:56 0:00 /usr/local/mysql/bin/mysqld --basedir=/usr/local/mysql --datadir=/data/mysql --plugin-dir=/usr/local/mysql/lib/plugin --user=mysql --log-error=/data/mysql/fonphxion.err --pid-file=/data/mysql/fonphxion.pid --socket=/tmp/mysql.sock root 17174 0.0 0.0 112664 968 pts/2 R+ 09:58 0:00 grep --color=auto mysql
转载于:https://blog.51cto.com/fonphxion/2049620