转载自:https://blog.csdn.net/shaochenshuo/article/details/50151525
1.版本
1)操作系统
cat /etc/issue
Red Hat Enterprise Linux Server release 5.5 (Tikanga)
Kernel \r on an \m
cat /proc/version
Linux version 2.6.32-504.el6.x86_64 ([email protected]) (gcc version 4.4.7 20120313 (Red Hat 4.4.7-11) (GCC) ) #1 SMP Wed
2)mysql数据库版本
mysql --version
mysql Ver 14.14 Distrib 5.1.73, for redhat-linux-gnu (x86_64) using readline 5.1
2.错误描述
今天启动一套5.1的mysql数据库的时候发现如下报错:
- 151202 18:38:02 mysqld_safe Starting mysqld daemon with databases from /data/mysql
- /usr/libexec/mysqld: Table 'mysql.plugin' doesn't exist
- 151202 18:38:02 [ERROR] Can't open the mysql.plugin table. Please run mysql_upgrade to create it.
- 151202 18:38:02 InnoDB: Initializing buffer pool, size = 3.9G
- 151202 18:38:03 InnoDB: Completed initialization of buffer pool
- 151202 18:38:03 InnoDB: Started; log sequence number 0 983066381
- 151202 18:38:04 [ERROR] Can't open and lock privilege tables: Table 'mysql.servers' doesn't exist
- 151202 18:38:04 [ERROR] Column count of mysql.db is wrong. Expected 22, found 20. Created with MySQL 50157, now running 50173. Please use mysql_upgrade to fix this error.
- 151202 18:38:04 [ERROR] mysql.user has no `Event_priv` column at position 29
- 151202 18:38:04 [ERROR] Cannot open mysql.event
- 151202 18:38:04 [ERROR] Event Scheduler: An error occurred when initializing system tables. Disabling the Event Scheduler.
- 151202 18:38:04 [Note] /usr/libexec/mysqld: ready for connections.
- Version: '5.1.73-log' socket: '/var/lib/mysql/mysql.sock' port: 3306 Source distribution
3.问题分析
具体是什么原因导致启动的时候报这些错误,还不知道
4.解决方案
1).根据error中的提示 我们可以使用mysql_upgrade来修复问题
mysql_upgrade --protocol=tcp -P3306 -p
输出如下:(截取部分)
- mysql_upgrade --protocol=tcp -P3306 -p
- Enter password:
- Looking for 'mysql' as: mysql
- Looking for 'mysqlcheck' as: mysqlcheck
- Running 'mysqlcheck' with connection arguments: '--protocol=tcp' '--port=3306'
- Running 'mysqlcheck' with connection arguments: '--protocol=tcp' '--port=3306'
- ccdb5.ScalingGroup OK
- ccdb5.cAdmin OK
- ccdb5.cAlarm OK
- ccdb5.cApp OK
- ccdb5.cAuth OK
- ccdb5.cCluster OK
- ccdb5.cContainerType OK
- ccdb5.cCvmInstance OK
- ccdb5.cCvmInstanceECC OK
- ccdb5.cDevice OK
- ccdb5.cDirtyAgentConf OK
- .......................................................
- .......................................................
2).重启mysql实例
mysqladmin -uroot -p -S /var/lib/mysql/mysql.sock shutdown
mysqld_safe --defaults-file=/etc/my.cnf &
启动时errolog日志截取如下:
- 151202 19:26:27 mysqld_safe mysqld from pid file /var/run/mysqld/mysqld.pid ended
- 151202 19:26:54 mysqld_safe Starting mysqld daemon with databases from /data/mysql
- 151202 19:26:54 InnoDB: Initializing buffer pool, size = 3.9G
- 151202 19:26:54 InnoDB: Completed initialization of buffer pool
- 151202 19:26:55 InnoDB: Started; log sequence number 0 983066391
- 151202 19:26:55 [Note] Event Scheduler: Loaded 0 events
- 151202 19:26:55 [Note] /usr/libexec/mysqld: ready for connections.
- Version: '5.1.73-log' socket: '/var/lib/mysql/mysql.sock' port: 3306 Source distribution