https://icesquare.com/wordpress/mysql-starting-mysql-error-the-server-quit-without-updating-pid-file/
https://blog.csdn.net/qq_35440678/article/details/56016264
Solution 1: Reboot The Computer
Although it sounds simple, but it really works. During the system upgrade, the OS may disable some of your daemons. Instead of troubleshooting each one by one, the easiest way is to start everything over. For example, I experienced this problem today after upgrading the Apache and Ruby (Yes, MySQL is not part of the update), and I got this error message afterward. After rebooting the computer, the error message is gone.
Solution 2: Remove Your MySQL Config File
If you have modified your MySQL configuration file, MySQL may not like it few versions after (MySQL is not backward compatibility friendly). It can be the problem of using an unsupported variable, or something similar. The easiest way is to remove your configuration file, and try to start the MySQL server again:
Backup your MySQL configuration first.
mv /etc/my.cnf /etc/my.cnf.backup
And restart the MySQL server again:
/usr/local/share/mysql/mysql.server start
Hopefully you will see the following message:
Starting MySQL. SUCCESS!
Solution 3: Upgrade Your Database File
Sometimes, the newer MySQL doesn’t like the database created in earlier version. I discovered this when I upgrade to MySQL 5.5.7:
Starting MySQL..... ERROR! The server quit without updating PID file (/var/db/mysql/www.icesquare.com.pid).
Since MySQL tells me which PID file causes the problem, I open the file and take a look what’s going on:
sudo tail /var/db/mysql/www.icesquare.com.err
And I saw something interesting: tables: Table ‘mysql.proxies_priv’ doesn’t exist:
101112 10:49:16 InnoDB: Initializing buffer pool, size = 128.0M 101112 10:49:16 InnoDB: Completed initialization of buffer pool 101112 10:49:16 InnoDB: highest supported file format is Barracuda. 101112 10:49:17 InnoDB: 1.1.3 started; log sequence number 1589404 101112 10:49:17 [ERROR] Fatal error: Can't open and lock privilege tables: Table 'mysql.proxies_priv' doesn't exist 101112 10:49:17 mysqld_safe mysqld from pid file /var/db/mysql/www.icesquare.com.pid ended
The reason is very simple. MySQL could not open a table created in the earlier version (< 5.7.7) because it is not compatible with the current version. So, we can try to start the MySQL in safe mode through rc.d. First, you can edit the /etc/rc.conf and put the following into the file:
mysql_enable="YES" mysql_args="--skip-grant-tables --skip-networking"
Restart MySQL through rc.d:
/usr/local/etc/rc.d/mysql-server start
If you did it right, you should see something like the following:
Starting MySQL.. SUCCESS!
Now, MySQL is already running the safe-mode. We want to perform a MySQL upgrade on all tables:
sudo mysql_upgrade
You should see something like this:
Looking for 'mysql' as: mysql Looking for 'mysqlcheck' as: mysqlcheck Running 'mysqlcheck' with connection arguments: '--port=3306' '--socket=/tmp/mysql.sock' Running 'mysqlcheck' with connection arguments: '--port=3306' '--socket=/tmp/mysql.sock' mysql.columns_priv OK mysql.db OK mysql.event OK mysql.func OK mysql.general_log OK mysql.help_category OK mysql.help_keyword OK mysql.help_relation OK mysql.help_topic OK mysql.host OK mysql.ndb_binlog_index OK mysql.plugin OK mysql.proc OK mysql.procs_priv OK mysql.servers OK mysql.slow_log OK mysql.tables_priv OK mysql.time_zone OK mysql.time_zone_leap_second OK mysql.time_zone_name OK mysql.time_zone_transition OK mysql.time_zone_transition_type OK mysql.user OK Running 'mysql_fix_privilege_tables'... OK
Now, we want to switch the MySQL back to normal mode by commenting the extra options in /etc/rc.conf:
mysql_enable="YES" #mysql_args="--skip-grant-tables --skip-networking"
And restart MySQL through /etc/rc.d:
/usr/local/etc/rc.d/mysql-server restart
Now the MySQL is up and running again!
Happy MySQLing.
出现问题的可能性
1、可能是/opt/mysql/data/数据目录mysql用户没有权限(修改数据目录的权限)
解决方法 :给予权限,执行 "chown -R mysql.mysql /opt/mysql/data" 然后重新启动mysqld
2、可能进程里已经存在mysql进程
解决方法:用命令“ps -ef|grep mysqld”查看是否有mysqld进程,如果有使用“kill -9 进程号”杀死,然后重新启动mysqld!
3、可能是第二次在机器上安装mysql,有残余数据影响了服务的启动。
解决方法:去mysql的二进制日志目录看看,如果存在mysql-binlog.index,就赶快把它删除掉吧
4、mysql在启动时没有指定配置文件时会使用/etc/my.cnf配置文件,请打开这个文件查看在[mysqld]下有没有指定数据目录(datadir)。
解决方法:请在[mysqld]下设置这一行:datadir = /opt/mysql/data
5、skip-federated字段问题
解决方法:检查一下/etc/my.cnf文件中有没有没被注释掉的skip-federated字段,如果有就立即注释掉吧。
6、错误日志目录不存在
解决方法:使用“chown” “chmod”命令赋予mysql所有者及权限
7、selinux惹的祸,如果是centos系统,默认会开启selinux
1
2
|
解决方法:先临时改为警告模式:[root@www php]
# setenforce 0
然后打开
/etc/sysconfig/selinux
,把SELINUX=enforcing改为SELINUX=disabled
|
8、启动失败注意检查数据目录的权限,要与mysql程序运行用户权限一致。
1
|
[root@db01 mysql]
# chown -R mysql.mysql ../mysql
|
最好是整个mysql程序目录都授权予mysql用户。
附加:
经验之谈:
还有一个原因可能是:
查看配置文件/usr/local/mysql/my.cnf里有没有innodb_buffer_pool_size这个参数
innodb_buffer_pool_size:主要作用是缓存innodb表的索引,数据,插入数据时的缓冲;
默认值:128M;
专用mysql服务器设置此值的大小: 系统内存的70%-80%最佳。
如果你的系统内存不大,查看这个参数,把它的值设置小一点吧
总结:
在配置文件/etc/my.cnf添加错误日志参数,一切问题都解决
1
2
|
[mysqld_safe]
log-error =
/data/mysql/logs/error
.log
|
启动报错时查看日志信息:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
#tail -f /data/mysql/logs/error.log
160721 06:12:07 mysqld_safe Starting mysqld daemon with databases from
/data/mysql/data
2016-07-21 06:12:10 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation
for
more
details).
2016-07-21 06:12:10 0 [Note]
/opt/mysql/bin/mysqld
(mysqld 5.6.27-log) starting as process 2290 ...
2016-07-21 06:12:10 2290 [Note] Plugin
'FEDERATED'
is disabled.
2016-07-21 06:12:10 2290 [Warning] The option innodb (skip-innodb) is deprecated and will be removed
in
a future release
2016-07-21 06:12:10 2290 [Note] InnoDB: Using atomics to ref count buffer pool pages
2016-07-21 06:12:10 2290 [Note] InnoDB: The InnoDB memory heap is disabled
2016-07-21 06:12:10 2290 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2016-07-21 06:12:10 2290 [Note] InnoDB: Memory barrier is not used
2016-07-21 06:12:10 2290 [Note] InnoDB: Compressed tables use zlib 1.2.3
2016-07-21 06:12:10 2290 [Note] InnoDB: Using CPU crc32 instructions
2016-07-21 06:12:10 2290 [Note] InnoDB: Initializing buffer pool, size = 128.0M
2016-07-21 06:12:10 2290 [Note] InnoDB: Completed initialization of buffer pool
2016-07-21 06:12:10 2290 [Note] InnoDB: Highest supported
file
format
is Barracuda.
2016-07-21 06:12:11 2290 [Note] InnoDB: 128 rollback segment(s) are active.
2016-07-21 06:12:11 2290 [Note] InnoDB: Waiting
for
purge to start
2016-07-21 06:12:11 2290 [Note] InnoDB: 5.6.27 started; log sequence number 1625997
2016-07-21 06:12:11 2290 [ERROR]
/opt/mysql/bin/mysqld
: unknown option
'--slave_parallel_workers=3'
2016-07-21 06:12:11 2290 [ERROR] Aborting
2016-07-21 06:12:11 2290 [Note] Binlog end
2016-07-21 06:12:11 2290 [Note] Shutting down plugin
'partition'
2016-07-21 06:12:11 2290 [Note] Shutting down plugin
'INNODB_SYS_DATAFILES'
2016-07-21 06:12:11 2290 [Note] Shutting down plugin
'INNODB_SYS_TABLESPACES'
2016-07-21 06:12:11 2290 [Note] Shutting down plugin
'INNODB_SYS_FOREIGN_COLS'
2016-07-21 06:12:11 2290 [Note] Shutting down plugin
'INNODB_SYS_FOREIGN'
2016-07-21 06:12:11 2290 [Note] Shutting down plugin
'INNODB_SYS_FIELDS'
|
发现日志输出
1
2
|
2016-07-21 06:12:11 2290 [ERROR]
/opt/mysql/bin/mysqld
: unknown option
'--slave_parallel_workers=3'
2016-07-21 06:12:11 2290 [ERROR] Aborting
|
肯定是配置文件里加入了这个错误参数,去掉即可
新加报错:
Starting MySQL.171019 10:11:54 mysqld_safe error: log-error set to '/data/tools/mysql/logs/error.log', however file don't exists. Create writable for user 'mysql'.
这是在mysql新版本:5.6.35,5.6.36的一个bug
参考:https://bugs.mysql.com/bug.php?id=84427
解决:
手动创建日志文件:
1
2
3
4
5
|
touch
/data/tools/mysql/logs/error
.log
chown
mysql.
/data/tools/mysql/logs/error
.log
/etc/init
.d
/mysqld
start
|