问题:MySQL无法正常启动
查看日志
2018-02-23T02:10:08.371209Z 0 [System] [MY-010116] /usr/sbin/mysqld (mysqld 8.0.4-rc-log) starting as process 27702 ...
2018-02-23T02:10:08.737713Z 1 [ERROR] [MY-011096] No data dictionary version number found.
2018-02-23T02:10:08.737989Z 0 [ERROR] [MY-010020] Data Dictionary initialization failed.
2018-02-23T02:10:08.738038Z 0 [ERROR] [MY-010119] Aborting
后来发现,升级后默认启用了caching_sha2_password身份认证机制,以前的数据是不能直接运行的。
只能先恢复原版本,将数据从原版本导出,重新导入使用,或再升级导入。
一、卸载MySQL8.0.4
备份数据
mv /var/lib/{mysqlMySQL文章入库助手,mysql.bak}
chown -R mysql:mysql /var/lib/mysql.bak
chmod 755 -R /var/lib/mysql.bak
直接yum卸载
rpm -qa|grep '^mysql'
然后将查询出的8.0.4的包全部yum卸载
二、安装MySQL8.0.3
从官方下载 8.0.3
下载打包版mysql-8.0.3-0.1.rc.el7.x86_64.rpm-bundle.tar
解压
tar -xvf mysql-8.0.3-0.1.rc.el7.x86_64.rpm-bundle.tar
然后依次安装common、libs、client、server
rpm -ivh mysql-community-common-8.0.3-0.1.rc.el7.x86_64.rpm
rpm -ivh mysql-community-libs-8.0.3-0.1.rc.el7.x86_64.rpm
rpm -ivh mysql-community-client-8.0.3-0.1.rc.el7.x86_64.rpm
rpm -ivh mysql-community-server-8.0.3-0.1.rc.el7.x86_64.rpm
启动mysql
systemctl start msyqld.service
此时/var/lib/重新生成了一个新的mysql文件夹
三、数据导出
修改/etc/my.cnf指向旧数据
[mysqld]
innodb_force_recovery = 6
datadir=/var/lib/mysql.bak
Forcing InnoDB Recovery提供了6个等级的修复模式
innodb_force_recovery 参考: https://www.linuxidc.com/Linux/2018-02/151049.htm
全库导出:
mysqldump -uroot -p --all-databases > /home/sqlfile.sql
四、数据恢复
修改/etc/my.cnf数据路径,去掉修复模式,修复模式下不可写
[mysqld]
datadir=/var/lib/mysql
查看临时密码
[root@soft]# cat /var/log/mysqld.log|grep password
2018-02-23T08:06:36.785974Z 5 [Note] A temporary password is generated for root@localhost: Leyk2qO_75ER
用临时密码登录mysqlmysql文章入库软件,修改密码
放弃升级,直接导入数据
mysql -uroot -p
mysql>GRANT ALL PRIVILEGES ON *.* TO 'root'@'localhost' IDENTIFIED BY 'abcdef@' WITH GRANT OPTION;
mysql>flush privileges;
mysql>source /home/sqlfile.sql;
重启后,一切正常。升级前一定要备份,一定要经常备份mysql文章入库软件。
文章地址:https://www.tianxianmao.com/article/other/MySQLgfyczjyumsjdhwfqd.html