MySQL 5.0 升级问题

MySQL 5.0 升级问题

我已将 Ubuntu 服务器从 8.04 LTS 更新至 10.04 LTS,但在安装 MySQL 服务器时遇到了问题。我执行的步骤如下:

1) Removed MySQL on Ubuntu 8.04
2) Updated OS to Ubuntu 10.04 LTS
3) Installed MySQL 5.1 from repositories
4) Stopped new MySQL server and ran mysql_upgrade

这是我收到的错误:

Looking for 'mysql' as: mysql
Looking for 'mysqlcheck' as: mysqlcheck
Running 'mysqlcheck' with connection arguments: '--port=3306' '--socket=/var/run/mysqld/mysqld.sock' 
mysqlcheck: Got error: 2002: Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2) when trying to connect
FATAL ERROR: Upgrade failed

以下是同时写入的日志条目:

111205  2:56:56 [Note] Plugin 'FEDERATED' is disabled.
111205  2:56:56  InnoDB: Started; log sequence number 52 181390868
111205  2:56:56 [ERROR] Column count of mysql.db is wrong. Expected 22, found 20. Created with MySQL 50051, now running 50141. Please use mysql_upgrade to fix this error.
111205  2:56:56 [ERROR] mysql.user has no `Event_priv` column at position 29
111205  2:56:56 [ERROR] Event Scheduler: An error occurred when initializing system tables. Disabling the Event Scheduler.
111205  2:56:56 [Note] /usr/sbin/mysqld: ready for connections.
Version: '5.1.41-3ubuntu12.10'  socket: '/var/run/mysqld/mysqld.sock'  port: 3306  (Ubuntu)
111205  2:56:57 [Note] /usr/sbin/mysqld: Normal shutdown

111205  2:56:57  InnoDB: Starting shutdown...
111205  2:56:57  InnoDB: Shutdown completed; log sequence number 52 181390868
111205  2:56:57 [Note] /usr/sbin/mysqld: Shutdown complete

有人能至少给我指出解决问题的正确方法吗?我在 Google 上搜索并花了很多时间尝试自己解决这个问题。感谢您的帮助。

更新 1

  • 我已经备份并删除/var/lib/mysql/mysql
  • 运行 mysql_install_db
  • mysqld --skip-grant-tables --user=mysql
  • mysql_upgrade

我收到以下错误:

root@server:~# mysql_upgrade 以以下方式查找“mysql”:mysql 以以下方式查找“mysqlcheck”:mysqlcheck 使用连接参数运行“mysqlcheck”:“--port=3306”“--socket=/var/run/mysqld/mysqld.sock” mysqlcheck:尝试连接时出现错误:2002:无法通过套接字“/var/run/mysqld/mysqld.sock”(111) 连接到本地 MySQL 服务器 致命错误:升级失败

答案1

备份所有 /var/lib/mysql/* 目录,然后删除 /var/lib/mysql/mysql 并运行

mysql_installdb

这将创建一个新的 mysql 数据库并允许你的服务器启动。然后要做的第一件事就是运行mysql_upgrade以迁移你的数据库。

相关内容