[mysql error]The server quit without updating PID file

发布 : 2017-04-12 分类 : IT 浏览 :

update: 2017年7月11日17:42

终极解决方案:
用brew安装mysql经常会碰到这些问题,直接用安装包安装后,从未复现

debug前须知:
mysql配置文件依次读取:

1
2
3
/etc/my.cnf
/etc/mysql/my.cnf
~/my.cnf

2017041214919952361252.png

网上提供的解决方法:

查看报错信息,有两处报错

err文件位于/usr/local/var/mysql/data
20170412149199540435226.png

- Can't open the mysql.plugin table. Please run mysql_upgrade to create it.
按照提示运行`mysql_upgrade`报错

20170412149199546335602.png
​ >mysql_upgrade: Got error: 2002: Can’t connect to local MySQL server through socket ‘/tmp/mysql.sock’ (2) while connecting to the MySQL server
Upgrade process encountered error and will not continue.

- Fatal error: Can't open and lock privilege tables: Table 'mysql.user' doesn't exist

检查是否有实例正在运行

1
ps -ef | grep mysql

20170412149199567567857.png
结果:没有

删除.err文件

20170412149199529841695.png
结果:无效

改变权限

1
sudo chown -R _mysql:mysql /usr/local/var/mysql

结果:无效

重新初始化

1
2
unset TMPDIR
mysql_install_db --verbose --user=`whoami` --basedir="$(brew --prefix mysql)" --datadir=/usr/local/var/mysql/data --tmpdir=/tmp

20170412149199560432948.png

因为/usr/local/var/mysql/data目录不为空,所以没法初始化,那么先清空目录,再初始化

1
2
3
4
unset TMPDIR
cd /usr/local/var/mysql/data
sudo rm *
mysql_install_db

再运行sudo mysql.server start命令启动,依然报错,查看目录文件权限,原来初始化的时候又改变权限了

1
sudo chown -R _mysql:mysql /usr/local/var/mysql

2017041214919969007399.png

DONE!

brew services start mysql与mysql.server start

2017-04-12T12:00:55.701485Z 1 [Note] A temporary password is generated for root@localhost: ZCBp1r-K0RlE

If you lose this password, please consult the section How to Reset the Root Password in the MySQL reference manual.

本文作者 : 小凡
原文链接 : https://16bh.github.io/2017/04/12/mysql-error-The-server-quit-without-updating-PID-file/
版权声明 : 本博客所有文章除特别声明外,均采用 CC BY-NC-SA 4.0 许可协议。转载请注明出处!
留下足迹