Can't open the mysql.plugin table. Please run mysql_upgrade to create it

转载自: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数据库的时候发现如下报错:

[html]  view plain  copy
  1. 151202 18:38:02 mysqld_safe Starting mysqld daemon with databases from /data/mysql  
  2. /usr/libexec/mysqld: Table 'mysql.plugin' doesn't exist  
  3. 151202 18:38:02 [ERROR] Can't open the mysql.plugin table. Please run mysql_upgrade to create it.  
  4. 151202 18:38:02  InnoDB: Initializing buffer pool, size = 3.9G  
  5. 151202 18:38:03  InnoDB: Completed initialization of buffer pool  
  6. 151202 18:38:03  InnoDB: Started; log sequence number 0 983066381  
  7. 151202 18:38:04 [ERROR] Can't open and lock privilege tables: Table 'mysql.servers' doesn't exist  
  8. 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.  
  9. 151202 18:38:04 [ERROR] mysql.user has no `Event_priv` column at position 29  
  10. 151202 18:38:04 [ERROR] Cannot open mysql.event  
  11. 151202 18:38:04 [ERROR] Event Scheduler: An error occurred when initializing system tables. Disabling the Event Scheduler.  
  12. 151202 18:38:04 [Note] /usr/libexec/mysqld: ready for connections.  
  13. 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

输出如下:(截取部分)

[html]  view plain  copy
  1. mysql_upgrade --protocol=tcp -P3306 -p  
  2. Enter password:   
  3. Looking for 'mysql' as: mysql  
  4. Looking for 'mysqlcheck' as: mysqlcheck  
  5. Running 'mysqlcheck' with connection arguments: '--protocol=tcp' '--port=3306'   
  6. Running 'mysqlcheck' with connection arguments: '--protocol=tcp' '--port=3306'   
  7. ccdb5.ScalingGroup                                 OK  
  8. ccdb5.cAdmin                                       OK  
  9. ccdb5.cAlarm                                       OK  
  10. ccdb5.cApp                                         OK  
  11. ccdb5.cAuth                                        OK  
  12. ccdb5.cCluster                                     OK  
  13. ccdb5.cContainerType                               OK  
  14. ccdb5.cCvmInstance                                 OK  
  15. ccdb5.cCvmInstanceECC                              OK  
  16. ccdb5.cDevice                                      OK  
  17. ccdb5.cDirtyAgentConf                              OK  
  18. .......................................................  
  19. .......................................................  

2).重启mysql实例

mysqladmin -uroot -p -S /var/lib/mysql/mysql.sock shutdown

mysqld_safe --defaults-file=/etc/my.cnf &

启动时errolog日志截取如下:

[html]  view plain  copy
  1. 151202 19:26:27 mysqld_safe mysqld from pid file /var/run/mysqld/mysqld.pid ended  
  2. 151202 19:26:54 mysqld_safe Starting mysqld daemon with databases from /data/mysql  
  3. 151202 19:26:54  InnoDB: Initializing buffer pool, size = 3.9G  
  4. 151202 19:26:54  InnoDB: Completed initialization of buffer pool  
  5. 151202 19:26:55  InnoDB: Started; log sequence number 0 983066391  
  6. 151202 19:26:55 [Note] Event Scheduler: Loaded 0 events  
  7. 151202 19:26:55 [Note] /usr/libexec/mysqld: ready for connections.  
  8. Version: '5.1.73-log'  socket: '/var/lib/mysql/mysql.sock'  port: 3306  Source distribution  
##可见错误已经修复

猜你喜欢

转载自blog.csdn.net/harryptter/article/details/79661798