![在 Centos 6 上从 MySQL 5.6 升级到 MariaDB 10 后,MySQL(又名 MariaDB)服务无法启动](https://linux22.com/image/740990/%E5%9C%A8%20Centos%206%20%E4%B8%8A%E4%BB%8E%20MySQL%205.6%20%E5%8D%87%E7%BA%A7%E5%88%B0%20MariaDB%2010%20%E5%90%8E%EF%BC%8CMySQL%EF%BC%88%E5%8F%88%E5%90%8D%20MariaDB%EF%BC%89%E6%9C%8D%E5%8A%A1%E6%97%A0%E6%B3%95%E5%90%AF%E5%8A%A8.png)
我需要一些帮助来弄清楚为什么在 Centos 6 上从 MySQL 5.6 升级到 MariaDB 10 如此困难。
以下是我正在使用的步骤,随后出现错误
cat /etc/centos-release
CentOS release 6.8 (Final)
mysql -V
mysql Ver 14.14 Distrib 5.6.35, for Linux (x86_64) using EditLine wrapper
yum -y update
mysqldump --all-databases -p > /tmp/backupdatabase.sql
cp /etc/my.cnf /tmp/my.cnf.bak
service mysqld stop
chkconfig mysqld off
yum remove mysql* mysql-server mysql-devel mysql-libs
edit /etc/yum.repos.d/mariadb.repo to point to MariaDB 10 source
yum clean all
yum install MariaDB-server galera MariaDB-client MariaDB-shared MariaDB-backup MariaDB-common
到目前为止一切看起来都很好:
service mysql start
service mysql start
Starting MariaDB.190801 13:39:12 mysqld_safe Logging to '/var/lib/mysql/designtv.designtv.net.err'.
190801 13:39:12 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql
...../etc/init.d/mysql: line 260: kill: (3056) - No such process
错误日志
190801 14:00:25 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql
190801 14:00:25 [ERROR] Can't read from messagefile '/usr/share/mysql/english/errmsg.sys'
/usr/libexec/mysqld: Unknown error 1146
190801 14:00:25 [ERROR] Can't open the mysql.plugin table. Please run mysql_upgrade to create it.
190801 14:00:25 InnoDB: Initializing buffer pool, size = 8.0M
190801 14:00:25 InnoDB: Completed initialization of buffer pool
190801 14:00:25 InnoDB: Started; log sequence number 0 44233
190801 14:00:25 [ERROR] Aborting
190801 14:00:25 InnoDB: Starting shutdown...
190801 14:00:30 InnoDB: Shutdown completed; log sequence number 0 44233
190801 14:00:30 [Note]
190801 14:00:30 mysqld_safe mysqld from pid file /var/lib/mysql/designtv.designtv.net.pid ended
“/var/lib/mysql/designtv.designtv.net.err” 是全世界可读的
ls -la /usr/share/mysql/english/errmsg.sys
-rw-r--r-- 1 root root 61764 Jan 29 2019 /usr/share/mysql/english/errmsg.sys
“[错误] 无法打开 mysql.plugin 表。请运行 mysql_upgrade 来创建它。”
在服务器运行之前,我无法运行 mysql_ugrade。
使用备份我完全删除了 /var/lib/mysql 中现有的数据库文件后进行了彻底的重新安装。
现在我收到此错误:
190801 16:50:40 InnoDB: Initializing buffer pool, size = 8.0M
190801 16:50:40 InnoDB: Completed initialization of buffer pool
InnoDB: Error: log file ./ib_logfile0 is of different size 0 50331648 bytes
InnoDB: than specified in the .cnf file 0 5242880 bytes!
190801 16:50:40 [ERROR] Plugin 'InnoDB' init function returned error.
190801 16:50:40 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed.
190801 16:50:40 [ERROR] Aborting
190801 16:50:40 [Note]
190801 16:50:40 mysqld_safe mysqld from pid file /var/lib/mysql/designtv.designtv.net.pid ended
190801 16:53:35 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql
190801 16:53:35 [ERROR] Can't read from messagefile '/usr/share/mysql/english/errmsg.sys'
190801 16:53:35 InnoDB: Initializing buffer pool, size = 8.0M
190801 16:53:35 InnoDB: Completed initialization of buffer pool
InnoDB: Error: log file ./ib_logfile0 is of different size 0 50331648 bytes
InnoDB: than specified in the .cnf file 0 5242880 bytes!
190801 16:53:35 [ERROR] Plugin 'InnoDB' init function returned error.
190801 16:53:35 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed.
190801 16:53:35 [ERROR] Aborting
答案1
您认为删除数据库文件后就进行了全新安装,但事实并非如此。
否则,第二个错误日志将不会表明 ib_logfile0 的大小与配置文件指定的大小不同。
至少你忘记删除 ib_logfile0 和 /etc/mysql 目录。
我建议你:
service mysql stop
killall -9 mysqld
mv /etc/mysql /etc/mysql.old
mv /var/lib/mysql /var/lib/mysql.old
此时,使用包管理器删除已安装的 mysql。
重新安装 mysql,它会要求您输入初始化详细信息,例如 root 密码等。
重新配置 mysql 以满足您的需要并重新启动它。
如果您有单独的备份,请逐个恢复数据库。避免恢复 mysql db 并手动重新创建所有用户。这对您来说会更容易。
这应该会带来更新且可正常运行的 mysql。