MySQL启动报【The server quit without updating PID file】错误的解决过程

1.凌乱的错误过程

MySQL启动时,一会儿报如下错误:

MySQL ERROR! The server quit without updating PID file  
mysqld_safe mysqld from pid file /var/run/mysqld/mysqld.pid ended

一会又报其他错误:

 The server quit without updating PID file (/var/run/mysqld/mysqld.pid).
 ```

看errlog又出现其他错误:

[Note] Plugin ‘FEDERATED’ is disabled.
/usr/sbin/mysqld: Table ‘mysql.plugin’ doesn’t exist
170220 14:19:39 [ERROR] Can’t open the mysql.plugin table. Please run mysql_upgrade to create it.

查看errlog和配置文件的方法:
> mysqld --verbose --help | grep cnf

07:02:57 UTC - mysqld got signal 11 ;
This could be because you hit a bug. It is also possible that this binary
or one of the libraries it was linked against is corrupt, improperly built,
or misconfigured. This error can also be caused by malfunctioning hardware.
We will try our best to scrape up some info that will hopefully help
diagnose the problem, but since we have already crashed,
something is definitely wrong and this may fail.

key_buffer_size=16777216
read_buffer_size=262144
max_used_connections=0
max_threads=10
thread_count=0
connection_count=0
It is possible that mysqld could use up to
key_buffer_size + (read_buffer_size + sort_buffer_size)*max_threads = 24179 K bytes of memory
Hope that’s ok; if not, decrease some variables in the equation.

Thread pointer: 0x7fff4460d950
Attempting backtrace. You can use the following information to find out
where mysqld died. If you see no messages after this, something went
terribly wrong…
stack_bottom = 7fff4460d420 thread_stack 0x40000
/usr/sbin/mysqld(my_print_stacktrace+0x20)[0x7fc13eedbeb0]
/usr/sbin/mysqld(handle_fatal_signal+0x3d5)[0x7fc13edc51f5]
/lib/x86_64-linux-gnu/libpthread.so.0(+0x10330)[0x7fc13db53330]
/usr/sbin/mysqld(_Z18ha_resolve_by_nameP3THDPK19st_mysql_lex_string+0x63)[0x7fc13edc69f3]
/usr/sbin/mysqld(_Z14open_table_defP3THDP11TABLE_SHAREj+0x28f5)[0x7fc13ed56c85]
/usr/sbin/mysqld(_Z15get_table_shareP3THDP10TABLE_LISTPcjjPij+0x1a2)[0x7fc13eca6b92]
/usr/sbin/mysqld(_Z10open_tableP3THDP10TABLE_LISTP11st_mem_rootP18Open_table_context+0x465)[0x7fc13ecae1e5]
/usr/sbin/mysqld(_Z11open_tablesP3THDPP10TABLE_LISTPjjP19Prelocking_strategy+0x551)[0x7fc13ecb0041]
/usr/sbin/mysqld(_Z20open_and_lock_tablesP3THDP10TABLE_LISTbjP19Prelocking_strategy+0x3c)[0x7fc13ecb075c]
/usr/sbin/mysqld(+0x271311)[0x7fc13ec59311]
/usr/sbin/mysqld(_Z11plugin_initPiPPci+0x8a2)[0x7fc13ecef4f2]
/usr/sbin/mysqld(+0x28b48b)[0x7fc13ec7348b]
/usr/sbin/mysqld(_Z11mysqld_mainiPPc+0x45b)[0x7fc13ec782fb]
/lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xf5)[0x7fc13d195f45]
/usr/sbin/mysqld(+0x287068)[0x7fc13ec6f068]

Trying to get some variables.
Some pointers may be invalid and cause the dump to abort.
Query (0): is an invalid pointer
Connection ID (thread ID): 0
Status: NOT_KILLED

The manual page at http://dev.mysql.com/doc/mysql/en/crashing.html contains
information that should help you find out what is causing the crash.
“`

2.解决过程(1):

一路google都找不到解决方法,只能重新初始化MySQL了!!!

重新创建:

mysqld –initialize –user=mysql –basedir=/usr/local/mysql –datadir=/home/mysql

等同于:

mysql_install_db –user=mysql –basedir=/opt/mysql/mysql –datadir=/opt/mysql/mysql/data

3.解决过程(2):

重新初始化后可以启动但是拿不到root密码,登录不进去,于是用skip-grant-tables不加载权限的方式启动,然后修改root密码:

/usr/local/mysql/bin/mysqld –basedir=/usr/local/mysql –datadir=/usr/local/mysql/var2 –plugin-dir=/usr/local/mysql/lib/plugin –user=mysql –log-error=/var/log/mysql.log –open-files-limit=65535 –pid-file=/usr/local/mysql/var2/ubuntu.pid –socket=/tmp/mysql.sock –port=3306 –skip-grant-tables

4.原因与反思

最后有个配置文件设置了myisam-recover

myisam-recover = BACKUP

最后发现根源是操作系统未安全关机,MySQL未能安全关闭,而系统表是用myisam引擎的,myisam不支持崩溃修复损坏,然后导致系统表损坏,而启动又检查myisam-recover,无法recover就无法启动了。
结论:虽然使用MySQL都强烈使用innodb引擎,但是系统表确是使用myisam.这个问题被折腾了一天,耗时太久,也说明自己对MySQL的不熟悉,尤其对于MySQL启动恢复部分,还有很长的一段路要走,多学习。

评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值