http://www.cnblogs.com/wjoyxt/p/5477072.html

不知道是不是每次更新 MySQL 软件之后都需要执行数据库升级指令?在我进行过的几次软件升级之后,总会在 MySQL 的日志中见到

“[ERROR] Missing system table mysql.proxies_priv; please run mysql_upgrade to create it”之类的错误。虽然这个错误修复起来很简单,却不容易引起注意。
1. 错误描述
我在好几次见到这样的错误提示之后才决定好好看看到底写了些什么。因为网站运行很正常,就心想应该不怎么重要吧。错误提示大致内容如下(已将前导的日期时间略去):

[ERROR] Missing system table mysql.proxies_priv; please run mysql_upgrade to create it
 [ERROR] Native table 'performance_schema'.'events_waits_current' has the wrong structure
 [ERROR] Native table 'performance_schema'.'events_waits_history' has the wrong structure
 [ERROR] Native table 'performance_schema'.'events_waits_history_long' has the wrong structure
 [ERROR] Native table 'performance_schema'.'setup_consumers' has the wrong structure
 [ERROR] Native table 'performance_schema'.'setup_instruments' has the wrong structure
 [ERROR] Native table 'performance_schema'.'setup_timers' has the wrong structure
 [ERROR] Native table 'performance_schema'.'performance_timers' has the wrong structure
 [ERROR] Native table 'performance_schema'.'threads' has the wrong structure
 [ERROR] Native table 'performance_schema'.'events_waits_summary_by_thread_by_event_name' has the wrong structure
 [ERROR] Native table 'performance_schema'.'events_waits_summary_by_instance' has the wrong structure
 [ERROR] Native table 'performance_schema'.'events_waits_summary_global_by_event_name' has the wrong structure
 [ERROR] Native table 'performance_schema'.'file_summary_by_event_name' has the wrong structure
 [ERROR] Native table 'performance_schema'.'file_summary_by_instance' has the wrong structure
 [ERROR] Native table 'performance_schema'.'mutex_instances' has the wrong structure
 [ERROR] Native table 'performance_schema'.'rwlock_instances' has the wrong structure
 [ERROR] Native table 'performance_schema'.'cond_instances' has the wrong structure
 [ERROR] Native table 'performance_schema'.'file_instances' has the wrong structure
 [Note] Event Scheduler: Loaded 0 events
 [Note] /usr/libexec/mysqld: ready for connections.
 Version: '5.5.20-log'  socket: '/var/lib/mysql/mysql.sock'  port: 0

有时候可能还会多点儿如下内容:

[ERROR] Incorrect definition of table mysql.proc: expected column 'comment' at position 15 to have type text, found type char(64).

一般看到结尾提示个 ready for connections 一般也就没心思去看前面都提示了什么东西了。我也是有一次在 x86_64 位 CentOS 中的 MySQL 日志中见到了多出来的这个 ERROR 信息才决定好好看看的前面的错误提示的。(我是运行在 32 位 CentOS 上的。)
可是见到错误提示句子结构都差不多就没有仔细往前翻,所以我开始还重新安装了一遍 MySQL 软件包。后来才看到每次执行
service mysql restart
重起 MySQL服务的时候都会出现这样的错误提示。然后该错误提示开头还说了,让执行
mysql_upgrade
指令来修复。才恍然大悟,估计是升级了 MySQL 的软件包,管理数据库的某些表结构发生了变化,所以还需要升级数据库的相关表结构。
2. 修复

mysql_upgrade -u root -p

然后根据提示输入 mysql 的 root 帐户密码,修复过程就可自动运行。此时会有如下形式的提示信息输出:

mysql_upgrade -u root -p
 Enter password:
 Looking for 'mysql' as: mysql
 Looking for 'mysqlcheck' as: mysqlcheck
 Running 'mysqlcheck' with connection arguments: '--port=3306' '--socket=/var/lib/mysql/mysql.sock'
 Running 'mysqlcheck' with connection arguments: '--port=3306' '--socket=/var/lib/mysql/mysql.sock'
 wp_commentmeta                               OK
 wp_comments                                  OK
 wp_links                                     OK
 wp_options                                   OK
 wp_postmeta                                  OK
 wp_posts                                     OK
 wp_term_relationships                        OK
 wp_term_taxonomy                             OK
 wp_terms                                     OK
 wp_usermeta                                  OK
 wp_users                                     OK
 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

看来每次在 Linux 中升级了 MySQL 软件包之后都需要进行类似的数据库升级操作。

修复 MySQL 数据库结构错误 – mysql_upgrade升级的更多相关文章

  1. MySQL数据表修复, 如何修复MySQL数据库(MyISAM / InnoDB)

    常用的Mysql数据库修复方法有下面3种: 1. mysql原生SQL命令: repair 即执行REPAIR TABLE SQL语句 语法:REPAIR TABLE tablename[,table ...

  2. 一次修复MySQL数据库的经历

    一次修复MySQL数据库的经历 实验室服务器的硬盘满了,结果导致一个线上服务的MySQL数据库的两个表坏了.具体症状是desc cdb_searchindex显示 ERROR 1017 (HY000) ...

  3. MYSQL 数据库结构优化

    数据库结构优化 优化数据大小 使表占用尽量少的磁盘空间.减少磁盘I/O次数及读取数据量是提升性能的基础原则.表越小,数据读写处理时则需要更少的内存,同时,小表的索引占用也相对小,索引处理也更加快速. ...

  4. 连接MySQL数据库得到错误“Unable to find the requested .Net Framework Data Provider”

      Registering DbProviderFactories Each .NET Framework data provider that supports a factory-based cl ...

  5. django中mysql数据库设置错误解决方法

    刚在django中settings.py进行设置mysql数据库. 当进行执行python manage.py shell命令时会报以下错误: 只需要在settings.py中 DATABASES = ...

  6. 启动Mysql数据库报错误:-bash: ./start.sh: Permission denied

    linux下安装好Mysql数据库后,输入启动命令: cd /home/homework/mysql && ./start.sh 回车后报如下错误: 原因是:该文件未有相关执行权限 解 ...

  7. mysql数据库1129错误

    错误:Host is blocked because of many connection errors; unblock with 'mysqladmin flush-hosts' 原因: 同一个i ...

  8. 《打造扛得住的MySQL数据库架构》第4章 MySQL数据库结构优化

    4-1 数据库结构优化介绍 良好的数据库逻辑设计和物理设计是数据库获得高性能的基础. 1.减少不必要的数据冗余. 2.尽量避免数据维护中出现更新,插入和删除异常. 插入异常:如果表中的某个实体随着另一 ...

  9. PowerDesigner中导入MYSQL数据库结构的步骤及问题解决

    今天在使用PowerDesigner,要导入MySql的表结构到PowerDesginer里, 记录下详细的操作步骤: 1.首先要确保机器安装了MySql的ODBC驱动,去http://dev.mys ...

随机推荐

  1. webstorm下设置sass

    关于sass,就不想多说什么了.只要你有css基础,十分钟入门好吗.可以参考下资料:http://www.w3cplus.com/sassguide/ 今天想说的是webStorm下如何实现sass自 ...

  2. WCF启用Session

    1 服务类添加ASPNETSESSION兼容标记 [System.ServiceModel.Activation.AspNetCompatibilityRequirements(Requirement ...

  3. 高精度+搜索+质数 BZOJ1225 [HNOI2001] 求正整数

    // 高精度+搜索+质数 BZOJ1225 [HNOI2001] 求正整数 // 思路: // http://blog.csdn.net/huzecong/article/details/847868 ...

  4. Tkinter教程之Event篇(3)

    本文转载自:http://blog.csdn.net/jcodeer/article/details/1823550 '''Tkinter教程之Event篇(3)''''''11.两个事件同时绑定到一 ...

  5. [Java基础]Java通配符

    转自:http://peiquan.blog.51cto.com/7518552/1303768 本以为这会是一篇比较基础的博客,可一旦深究的时候,才发现很多有意思的东西,也发现了很多令人迷惑的地方. ...

  6. Struts2类型转换器

    概述 A .从一个HTML 表单到一个 Action 对象,类型转换是从字符串到非字符串.    –HTTP没有"类型" 的概念.每一项表单输入只可能是一个字符串或一个字符串数组. ...

  7. Android程序的安全系统【转】

    最近在移植Android过程中遇到了Android程序(apk)权限的问题.最近也对这方面进行了一些了解,在此和大家分享. Android框架是基于Linux内核构建,所以Android安全系统也是基 ...

  8. HTTP协议状态码详解

    HTTP状态码,我都是现查现用. 我以前记得几个常用的状态码,比如200,302,304,404, 503. 一般来说我也只需要了解这些常用的状态码就可以了.  如果是做AJAX,REST,网络爬虫, ...

  9. VB.NET开发中遇到的一点小问题

    在用vb.net开发的security support时,遇到一个问题,在trainingCourses.aspx页面上增加了一个HyperLink控件 <asp:HyperLink runat ...

  10. POJ 3670 Eating Together (DP,LIS)

    题意:给定 n 个数,让你修改最少的数,使得它变成一个不下降或者不上升序列. 析:这个就是一个LIS,但是当时并没有看出来...只要求出最长LIS的长度,用总数减去就是答案. 代码如下: #inclu ...