`mysql_upgrade`失败,没有真正的理由

我从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 

通过mysqladmin shutdownclosuresmysqld --skip-grant-tables并通过service mysql start重新启动service 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 

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

 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_upgrade -u root -p 

    如果我不通过他们,我得到你的错误

    编辑 :感谢现在的意见,我知道还有其他的原因,也许不太频繁,但最好也意识到他们

    所以你得到那个错误的时候

    • 你没有通过用户名和密码
    • 你通过了你的证书,但他们错了
    • MySQL服务器没有运行
    • 权限'表被破坏(然后你必须用mysqld --skip-grant-table重新启动MySQL)
    • mysql.plugin表丢失了(当你启动MySQL时,你会看到一个错误提示:mysql_upgrade,但是失败了,你可能在my.cnf中有一些过时的configuration)

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

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

    这似乎是一个Plesk服务器,当使用Plesk时,Mysql没有root权限,但Mysql的pipe理员名为admin,所以这个命令应该可以在Plesk上工作,

     mysql_upgrade -uadmin -p`cat /etc/psa/.psa.shadow` 

    你可以尝试一个一个地运行,看看它失败的地方:

    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

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

    简而言之:错误是误导性的! 用DB在线运行mysql_upgrade -u root -p并提供root密码。

    这个问题非常普遍,我对此表示歉意。

    我找不到解决我遇到的问题的直接原因和解决scheme,于是我重新安装了MySQL,看看是否可行。 原来,重新安装的伎俩。 这是一个蹩脚的方式来解决,但这是我留下的唯一select。

    在这个问题上的其他很多答案都是我不得不通过最初运行mysql_upgrade来解决的问题,但是无论出于什么原因 – 它试图运行一些自动化查询都失败了,而且我找不到在哪个文档上查询它正在运行,所以我可以修复它们。

    你必须检查mysql数据下的所有文件的权限。 它应该是mysql PID(mysql或_mysql)的所有者。 有时候会发生这种情况,因为没有正确的许可就从文件恢复数据 例如,如果你的MySQL数据在/ var / lib / mysql下

     chown -R mysql /var/lib/mysql 

    我们的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带来适当的configuration设置

    • my.cnf.rpmsave恢复到原始状态(首先检查是否应添加新的默认设置!)

    • 使用像vimdiff这样的diff工具将my.cnf.rpmsave与新的my.cnf进行比较,并重新调整对MySQLconfiguration的调整,包括InnoDB设置。

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

    我做了最后的select,然后才能启动MySQL:

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

    现在mysql_upgrade工作正常,使用mysql_upgrade -uroot -p所以它提示我inputroot密码。

     [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。
    • 利润。

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

    我将这个系统从Mint 12升级到Mint 15后,我也遇到了这个问题。我已经存档了/ var / lib / mysql,并将它放回到升级后的位置。 我从user16081的评论运行了第一个mysqlcheck ,并且抱怨了mysql.sock。

    我开始使用/usr/sbin/mysqld &mysql_upgrade运行良好。

    我遇到了同样的问题。
    我通过包含-S /path/to/mysql.sock来解决它

    在我的具体情况下,mysql_upgrade的输出是:
    寻找“MySQL”为:mysql
    寻找“mysqlcheck”为:mysqlcheck
    致命错误:升级失败

    这是相当无用的。 –verbose没有任何区别。

    塞满了我解决了以下命令,它像一个魅力工作:
    mysql_upgrade -S /var/lib/mysql/mysql.sock -uUSERNAME -p

    希望它有帮助。

    我面对这个问题,我发现,

    1. 它需要MySQL服务运行

    2. 它需要用户名和密码

    我遇到了同样的问题。

    我通过mysql_install_db --user=mysql安装新的数据库来解决这个问题,如我在/ etc中的rc.mysql文件的注释中所述。

    然后,我能够启动mysql守护进程,并使用“MySQL”或任何你想连接与MySQL包。

    我在slackwarearm上遇到了这个问题,但是在这种情况下并不重要。

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

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

    我的错误可能是由套接字path的权限造成的,但是没有时间来validation它是什么原因。

    在我的情况下,我有几个版本的mysqld本地运行,使mysql_upgrade失败, 错误:取得服务器版本时失败! 可能是由于未经授权的访问。 ps aux | grep mysql ps aux | grep mysql并确保mysqld全部closures。 然后brew卸载所有版本,重新安装正确的版本。 之后,mysql_upgrade开始工作。

    尝试

     mysql_upgrade --verbose 

    或甚至(或两者)

     --debug-check --debug-info 

    MySQL的root用户名为“admin”,而不是root。 正确的命令是

     mysql_upgrade -uadmin -p