AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / server / 问题 / 527422
Accepted
Jim Rubenstein
Jim Rubenstein
Asked: 2013-07-31 12:21:30 +0800 CST2013-07-31 12:21:30 +0800 CST 2013-07-31 12:21:30 +0800 CST

`mysql_upgrade` 在没有给出真正原因的情况下失败

  • 772

我正在从 MySQL 5.1 升级到 5.5,运行mysql_upgrade并获得以下输出:

# mysql_upgrade
Looking for 'mysql' as: mysql
Looking for 'mysqlcheck' as: mysqlcheck
FATAL ERROR: Upgrade failed

关于在哪里寻找正在发生的事情(或者,没有发生?)的任何想法,以便我可以修复任何错误并实际运行mysql_upgrade?

谢谢!

更多输出:

# mysql_upgrade --verbose
Looking for 'mysql' as: mysql
Looking for 'mysqlcheck' as: mysqlcheck
FATAL ERROR: Upgrade failed

# mysql_upgrade --debug-check --debug-info
Looking for 'mysql' as: mysql
Looking for 'mysqlcheck' as: mysqlcheck
FATAL ERROR: Upgrade failed

# mysql_upgrade --debug-info
Looking for 'mysql' as: mysql
Looking for 'mysqlcheck' as: mysqlcheck
FATAL ERROR: Upgrade failed

User time 0.00, System time 0.00
Maximum resident set size 1260, Integral resident set size 0
Non-physical pagefaults 447, Physical pagefaults 0, Swaps 0
Blocks in 0 out 16, Messages in 0 out 0, Signals 0
Voluntary context switches 9, Involuntary context switches 5

# mysql_upgrade --debug-check
Looking for 'mysql' as: mysql
Looking for 'mysqlcheck' as: mysqlcheck
FATAL ERROR: Upgrade failed

关闭mysqld --skip-grant-tablesviamysqladmin shutdown并重新启动 mysql viaservice mysql start后,错误日志会一遍又一遍地循环这组错误:

130730 21:03:27 [Note] Plugin 'FEDERATED' is disabled.
/usr/sbin/mysqld: Table 'mysql.plugin' doesn't exist
130730 21:03:27 [ERROR] Can't open the mysql.plugin table. Please run mysql_upgrade to create it.
130730 21:03:27 InnoDB: The InnoDB memory heap is disabled
130730 21:03:27 InnoDB: Mutexes and rw_locks use GCC atomic builtins
130730 21:03:27 InnoDB: Compressed tables use zlib 1.2.3.4
130730 21:03:27 InnoDB: Initializing buffer pool, size = 20.0G
130730 21:03:29 InnoDB: Completed initialization of buffer pool
130730 21:03:30 InnoDB: highest supported file format is Barracuda.
InnoDB: Log scan progressed past the checkpoint lsn 588190222435
130730 21:03:30  InnoDB: Database was not shut down normally!
InnoDB: Starting crash recovery.
InnoDB: Reading tablespace information from the .ibd files...
InnoDB: Restoring possible half-written data pages from the doublewrite
InnoDB: buffer...
InnoDB: Doing recovery: scanned up to log sequence number 588192055067
130730 21:03:30  InnoDB: Starting an apply batch of log records to the database...
InnoDB: Progress in percents: 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 
InnoDB: Apply batch completed
InnoDB: Last MySQL binlog file position 0 81298895, file name /var/log/mysql/mysql-bin.006008
130730 21:03:33  InnoDB: Waiting for the background threads to start
130730 21:03:34 InnoDB: 5.5.32 started; log sequence number 588192055067
130730 21:03:34 [Note] Recovering after a crash using /var/log/mysql/mysql-bin
130730 21:03:34 [Note] Starting crash recovery...
130730 21:03:34 [Note] Crash recovery finished.
130730 21:03:34 [Note] Server hostname (bind-address): '0.0.0.0'; port: 3306
130730 21:03:34 [Note]   - '0.0.0.0' resolves to '0.0.0.0';
130730 21:03:34 [Note] Server socket created on IP: '0.0.0.0'.
130730 21:03:34 [ERROR] Fatal error: Can't open and lock privilege tables: Table 'mysql.host' doesn't exist

启动期间的 MySQL 日志通过mysqld_safe --skip-grant-tables

130730 21:19:36 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql
130730 21:19:36 [Note] Plugin 'FEDERATED' is disabled.
130730 21:19:36 InnoDB: The InnoDB memory heap is disabled
130730 21:19:36 InnoDB: Mutexes and rw_locks use GCC atomic builtins
130730 21:19:36 InnoDB: Compressed tables use zlib 1.2.3.4
130730 21:19:37 InnoDB: Initializing buffer pool, size = 20.0G
130730 21:19:39 InnoDB: Completed initialization of buffer pool
130730 21:19:39 InnoDB: highest supported file format is Barracuda.
130730 21:19:42  InnoDB: Warning: allocated tablespace 566, old maximum was 0
130730 21:19:42  InnoDB: Waiting for the background threads to start
130730 21:19:43 InnoDB: 5.5.32 started; log sequence number 588192055067
130730 21:19:43 [Note] Server hostname (bind-address): '0.0.0.0'; port: 3306
130730 21:19:43 [Note]   - '0.0.0.0' resolves to '0.0.0.0';
130730 21:19:43 [Note] Server socket created on IP: '0.0.0.0'.
130730 21:19:43 [Warning] Can't open and lock time zone table: Table 'mysql.time_zone_leap_second' doesn't exist trying to live without them
130730 21:19:43 [ERROR] Can't open and lock privilege tables: Table 'mysql.servers' doesn't exist
130730 21:19:43 [ERROR] Native table 'performance_schema'.'events_waits_current' has the wrong structure
130730 21:19:43 [ERROR] Native table 'performance_schema'.'events_waits_history' has the wrong structure
130730 21:19:43 [ERROR] Native table 'performance_schema'.'events_waits_history_long' has the wrong structure
130730 21:19:43 [ERROR] Native table 'performance_schema'.'setup_consumers' has the wrong structure
130730 21:19:43 [ERROR] Native table 'performance_schema'.'setup_instruments' has the wrong structure
130730 21:19:43 [ERROR] Native table 'performance_schema'.'setup_timers' has the wrong structure
130730 21:19:43 [ERROR] Native table 'performance_schema'.'performance_timers' has the wrong structure
130730 21:19:43 [ERROR] Native table 'performance_schema'.'threads' has the wrong structure
130730 21:19:43 [ERROR] Native table 'performance_schema'.'events_waits_summary_by_thread_by_event_name' has the wrong structure
130730 21:19:43 [ERROR] Native table 'performance_schema'.'events_waits_summary_by_instance' has the wrong structure
130730 21:19:43 [ERROR] Native table 'performance_schema'.'events_waits_summary_global_by_event_name' has the wrong structure
130730 21:19:43 [ERROR] Native table 'performance_schema'.'file_summary_by_event_name' has the wrong structure
130730 21:19:43 [ERROR] Native table 'performance_schema'.'file_summary_by_instance' has the wrong structure
130730 21:19:43 [ERROR] Native table 'performance_schema'.'mutex_instances' has the wrong structure
130730 21:19:43 [ERROR] Native table 'performance_schema'.'rwlock_instances' has the wrong structure
130730 21:19:43 [ERROR] Native table 'performance_schema'.'cond_instances' has the wrong structure
130730 21:19:43 [ERROR] Native table 'performance_schema'.'file_instances' has the wrong structure
130730 21:19:43 [Note] /usr/sbin/mysqld: ready for connections.
Version: '5.5.32-0ubuntu0.12.04.1-log'  socket: '/var/run/mysqld/mysqld.sock'  port: 3306  (Ubuntu)

据我了解,所有表结构/存在问题(与 mysql 系统表有关)都应通过运行来纠正mysql_upgrade:

mysql
  • 18 18 个回答
  • 128278 Views

18 个回答

  • Voted
  1. Riccardo Galli
    2013-08-15T02:01:50+08:002013-08-15T02:01:50+08:00

    我认为它需要用户名和密码

    mysql_upgrade -u root -p
    

    如果我不通过它们,我会收到您的错误

    编辑:感谢现在的评论,我知道还有其他原因,可能不那么频繁,但最好也了解它们

    所以你得到那个错误时

    • 你没有传递用户名和密码
    • 您通过了您的凭据,但它们是错误的
    • MySQL 服务器没有运行
    • 权限表被破坏(然后你必须重新启动 MySQL mysqld --skip-grant-table)
    • 缺少表 mysql.plugin(在启动 MySQL 时,您会看到一个错误提示运行... mysql_upgrade,并且失败。您可能在 my.cnf 中有一些过时的配置)
    • 97
  2. Aubrey Falconer
    2013-08-20T11:33:44+08:002013-08-20T11:33:44+08:00

    我刚刚从 5.5 升级到 5.6 时遇到了这些精确症状,结果证明是服务可达性问题。

    即使 cli MySQL 客户端可以仅通过提供 -u 和 -p 连接到我的本地数据库实例,我也需要为 mysql_upgrade 指定 -h 127.0.0.1,因为它正在尝试套接字文件连接并且在尝试中惨遭失败。

    • 10
  3. linuxman1
    2015-10-10T00:56:43+08:002015-10-10T00:56:43+08:00

    这似乎是一个 Plesk 服务器,当使用 Plesk 时,Mysql 没有 root,但是 Mysql 的管理员称为 admin,所以这个命令应该可以在 Plesk 上运行,就像我之前尝试过的那样:

    mysql_upgrade -uadmin -p`cat /etc/psa/.psa.shadow`
    
    • 9
  4. user16081-JoeT
    2013-07-31T13:10:32+08:002013-07-31T13:10:32+08:00

    您可以尝试一一运行它们以查看失败的位置:

    mysql_upgrade 执行以下命令来检查和修复表并升级系统表:

    mysqlcheck --all-databases --check-upgrade --auto-repair  
    mysql < fix_priv_tables  
    mysqlcheck --all-databases --check-upgrade --fix-db-names --fix-table-names
    

    来自http://dev.mysql.com/doc/refman/5.5/en/mysql-upgrade.html

    • 5
  5. Dr. Gianluigi Zane Zanettini
    2013-12-01T02:23:35+08:002013-12-01T02:23:35+08:00

    同样的问题!我的解决方案来自http://www.freebsd.org/cgi/query-pr.cgi?pr=180624

    简而言之:错误具有误导性!在线运行mysql_upgrade -u root -p数据库并提供root密码。

    • 5
  6. Ronnie
    2014-09-03T11:20:07+08:002014-09-03T11:20:07+08:00

    我们的 DBA 卸载了 mysql 版本 5.0.95,而不是仅仅升级到 5.5.39。卸载备份/etc/my.cnf到/etc/my.cnf.rpmsave然后将其删除,这会阻止 MySQL 正常启动:

    140902 15:00:57 [ERROR] Plugin 'InnoDB' init function returned error.
    140902 15:00:57 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed.
    140902 15:00:57 [ERROR] Unknown/unsupported storage engine: InnoDB
    140902 15:00:57 [ERROR] Aborting
    

    您可以执行以下任何操作:

    • 手动比较 my.cnf 文件并为 InnoDB 带来适当的配置设置

    • 恢复my.cnf.rpmsave原来的背面(首先检查您应该添加的任何新的默认设置!)

    • 使用 diff 工具vimdiff比较my.cnf.rpmsave新的my.cnf,并带回对 MySQL 配置进行的调整,包括 InnoDB 设置。

      [root]# vimdiff /etc/my.cnf /etc/my.cnf.rpmsave

    我做了最后一个选项,然后能够启动 MySQL:

    root]# service mysqld start
    Starting mysqld:                                           [  OK  ]
    

    现在mysql_upgrade工作正常,使用mysql_upgrade -uroot -p它提示我输入root密码。

    [root]# mysql_upgrade -uroot -p
    Enter password:
    Looking for 'mysql' as: mysql
    Looking for 'mysqlcheck' as: mysqlcheck
    Running 'mysqlcheck with default connection arguments
    ....
    

    希望这可以帮助!

    并且还使用mysql_upgrade -uroot -p失败,因为它需要运行 MySQL!

    得到教训:

    • 升级前备份 my.cnf ......实际上进行就地升级而不是卸载然后安装较新版本。
    • 让 MySQL 运行,以便您可以使用 mysql_upgrade。
    • 利润。
    • 3
  7. Best Answer
    Jim Rubenstein
    2013-12-01T06:00:11+08:002013-12-01T06:00:11+08:00

    这个问题非常笼统,对此我深表歉意。

    我找不到解决问题的直接原因和解决方案,因此我求助于重新安装 MySQL 以查看是否可行。事实证明,重新安装成功了。那是一种蹩脚的方法来修复它,但这是我剩下的唯一选择。

    关于这个问题的许多其他答案都是我必须解决的问题才能让 mysql_upgrade 最初运行,但无论出于何种原因 - 它在尝试运行一些自动查询时失败了,我找不到关于查询它正在运行,所以我可以修复它们。

    • 3
  8. asofyan
    2013-11-07T16:12:14+08:002013-11-07T16:12:14+08:00

    您必须检查mysql数据下所有文件的权限。它应该是 mysql PID(mysql 或 _mysql)的同一所有者。有时会发生这种情况,因为未经适当许可从文件中恢复数据。例如,如果您的 mysql 数据位于 /var/lib/mysql 下

    chown -R mysql /var/lib/mysql
    
    • 2
  9. Leandro Dardini
    2015-07-21T23:36:26+08:002015-07-21T23:36:26+08:00

    对我来说同样的问题,但我的问题的根源是旧密码格式。虽然可以通过“skip-secure-auth”强制使用旧格式连接 mysql,但 mysql_upgrade 没有此选项。您需要首先使用新格式更新 root 密码,然后才能升级您的 mysql。

    • 1
  10. Capt
    2016-01-26T09:54:25+08:002016-01-26T09:54:25+08:00

    从 5.1 升级到 5.5 时遇到同样的问题。

    这对我有用: sudo mysql_upgrade -S <path-to-socket> -u <myuser> -p<mypass>

    我的错误可能是由对套接字路径的权限引起的,但没有时间验证它是否是原因。

    • 1

相关问题

  • 开源与专有关系 db mgt 系统的优缺点是什么?

  • 在 solaris 10 上为 mysql 设置 max_allowed_pa​​cket

  • 如何移动 MySQL 的数据目录?

  • 通过 VPN 连接什么是远程服务器 IP?

  • mysql崩溃

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    新安装后 postgres 的默认超级用户用户名/密码是什么?

    • 5 个回答
  • Marko Smith

    SFTP 使用什么端口?

    • 6 个回答
  • Marko Smith

    命令行列出 Windows Active Directory 组中的用户?

    • 9 个回答
  • Marko Smith

    什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同?

    • 3 个回答
  • Marko Smith

    如何确定bash变量是否为空?

    • 15 个回答
  • Martin Hope
    Tom Feiner 如何按大小对 du -h 输出进行排序 2009-02-26 05:42:42 +0800 CST
  • Martin Hope
    Noah Goodrich 什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同? 2009-05-19 18:24:42 +0800 CST
  • Martin Hope
    Brent 如何确定bash变量是否为空? 2009-05-13 09:54:48 +0800 CST
  • Martin Hope
    cletus 您如何找到在 Windows 中打开文件的进程? 2009-05-01 16:47:16 +0800 CST

热门标签

linux nginx windows networking ubuntu domain-name-system amazon-web-services active-directory apache-2.4 ssh

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve