mysql5.6.40升级到mysql8.0.11 的步骤

mysql5.6.40升级到mysql8.0.11 的步骤

Posted by ivo on September 5, 2018

「转载文章」 环境: 操作系统: rhel7.5

目标: mysql 5.6.22升级到mysql 8.0.11


mysql5.6.40升级到mysql8.0.11,不能直接升级,如果直接升级8.0.11,启动会报以下不支持redo log format 错误:

2018-07-08T09:42:27.Z 1 [ERROR] [MY-0] [InnoDB] InnoDB: Unsupported redo log format (0). The redo log was created before MySQL 5.7.9 2018-07-08T09:42:27.Z 1 [ERROR] [MY-0] [InnoDB] InnoDB: Plugin initialization aborted with error Generic error. 2018-07-08T09:42:28.Z 1 [ERROR] [MY-0] [Server] Failed to initialize DD Storage Engine. 2018-07-08T09:42:28.Z 0 [ERROR] [MY-0] [Server] Data Dictionary initialization failed. 2018-07-08T09:42:28.Z 0 [ERROR] [MY-0] [Server] Aborting

正确的升级路径为:

mysql5.6.40–>mysql5.7.22–>mysql8.0.11

以下为具体的步骤。 1.准备步骤

–建立软件存储目录 mkdir /setup/mysql

–建立软件及数据目录 mkdir /data/db -p mkdir /mysql

–建立mysql组和用户

groupadd mysql useradd -g mysql mysql

–修改权限 chown -R mysql:mysql /data/db /mysql chmod -R 775 /data/db /mysql

–软件上传到 /setup/mysql ls -ltr /setup/mysql -rw-r–r–. 1 root root Jul 7 22:35 mysql-8.0.11-el7-x86_64.tar.gz -rw-r–r–. 1 root root Jul 8 15:05 mysql-5.6.40-linux-glibc2.12-x86_64.tar.gz -rw-r–r–. 1 root root Jul 8 18:07 mysql-5.7.22-el7-x86_64.tar.gz

–解压软件 –切换到mysql用户登陆 su - mysql

–进入到 /mysql

cd /mysql –解压5.6.40

tar xzvf /setup/mysql/mysql-5.6.40-linux-glibc2.12-x86_64.tar.gz -C /mysql mv mysql-5.6.40-linux-glibc2.12-x86_64 mysql-5.6.40

–解压5.7.22 tar xzvf /setup/mysql/mysql-5.7.22-el7-x86_64.tar.gz -C /mysql mv mysql-5.7.22-el7-x86_64 mysql-5.7.22

–解压8.0.11 tar xzvf /setup/mysql/mysql-8.0.11-el7-x86_64.tar.gz -C /mysql

mv mysql-8.0.11-el7-x86_64 mysql-8.0.11

2.启动5.6.40 cd /mysql/mysql-5.6.40

–初始化mysql –以 mysql用户 完成 $ ./scripts/mysql_install_db–basedir=/mysql/mysql-5.6.40 –datadir=/data/db/–log-error=/data/db/mysql-error.log –socket=/data/db/mysql.sock –user=mysql

启动mysql server:

$ ./bin/mysqld_safe–basedir=/mysql/mysql-5.6.40 –datadir=/data/db/–log-error=/data/db/mysql-error.log –socket=/data/db/mysql.sock &

修改mysql实例root口令:

./bin/mysqladmin -uroot -S/data/db/mysql.sock password ‘mysql’

3.mysql 5.6.40升级到5.7.22 3.1 停 mysql server 5.6:

$ cd /mysql/mysql-5.6.40

$ ./bin/mysql -uroot -p -S /data/db/mysql.sock

修改global变量innodb_fast_shutdown=0:

mysql> set globalinnodb_fast_shutdown=0;

–关闭数据库

$ ./bin/mysqladmin -uroot -p -S/data/db/mysql.sock shutdown

3.2 通过mysql server 5.7启动mysql实例:

$ cd /mysql/mysql-5.7.22

$ ./bin/mysqld_safe–socket=/data/db/mysql.sock –basedir=/mysql/mysql-5.7.22 –datadir=/data/db/–log-error=/data/db/mysql-error.log &

3.3 确认mysql已经启动,日志中数据库已经启动

$ ps -ef|grep mysql $ tail -100f /data/db/mysql-error.log

2018-07-09T04:24:20.0Z 0 [Note] /mysql/mysql-5.7.22/bin/mysqld: ready for connections. Version: ‘5.7.22’ socket: ‘/data/db/mysql.sock’ port: 3306 MySQL Community Server (GPL)

3.4 升级.mysql实例数据字典:

$ ./bin/mysql_upgrade -uroot -p -S/data/db/mysql.sock

下面是过程信息:

Checking if update is needed. Checking server version. Running queries to upgrade MySQL server. Checking system database. mysql.columns_priv OK mysql.db OK mysql.engine_cost OK mysql.event OK 。。。 mysql.time_zone_transition_type OK mysql.user OK Upgrading the sys schema. Checking databases. sys.sys_config OK Upgrade process completed successfully. Checking if update is needed.

3.5 重启mysql 5.7实例:

./bin/mysqladmin -uroot -p -S/data/db/mysql.sock shutdown

./bin/mysqld_safe –socket=/data/db/mysql.sock–basedir=/mysql/mysql-5.7.22 –datadir=/data/db/–log-error=/data/db/mysql-error.log &

3.6 检查升级后mysql server版本:

./bin/mysql -uroot -pmysql -S /data/db/mysql.sock

mysql> select version();

+———–+ | version() | +———–+ | 5.7.22 | +———–+ 1 row in set (0.00 sec)

–还应该检查日志文件,是否有错误出现。

到5.7.22的升级结束

4.mysql 5.7.22升级到8.0.11 4.1 先修改 innodb_fast_shutdown =0

$ cd /mysql/mysql-5.7.22

$ ./bin/mysql -uroot -p -S /data/db/mysql.sock

mysql> set globalinnodb_fast_shutdown=0;

4.2 停 mysql server 5.7

cd /mysql/mysql-5.7.22

$ ./bin/mysqladmin -uroot -p -S/data/db/mysql.sock shutdown

4.3 通过mysql server 8.0.11启动mysql实例:

$ cd /mysql/mysql-8.0.11

$ ./bin/mysqld_safe–socket=/data/db/mysql.sock –basedir=/mysql/mysql-8.0.11 –datadir=/data/db/–log-error=/data/db/mysql-error.log &

4.4 确认mysql已经启动,日志中数据库已经启动

$ ps -ef|grep mysql $ tail -100f /data/db/mysql-error.log

[System] [MY-0] [Server] /mysql/mysql-8.0.11/bin/mysqld: ready for connections. Version: ‘8.0.11’ socket: ‘/data/db/mysql.sock’ port: 3306 MySQL Community Server - GPL.

4.5 升级.mysql实例数据字典 $ cd /mysql/mysql-8.0.11 $ ./bin/mysql_upgrade -uroot -p -S/data/db/mysql.sock

下面是过程信息:

Checking if update is needed. Checking server version. Running queries to upgrade MySQL server. Checking system database. mysql.columns_priv OK mysql.db OK mysql.engine_cost OK mysql.event OK 。。。 mysql.time_zone_transition_type OK mysql.user OK Upgrading the sys schema. Checking databases. sys.sys_config OK Upgrade process completed successfully. Checking if update is needed.

4.6 重启mysql 8.0.11实例

$ cd /mysql/mysql-8.0.11

$ ./bin/mysqladmin -uroot -p -S/data/db/mysql.sock shutdown

$ ./bin/mysqld_safe –socket=/data/db/mysql.sock–basedir=/mysql/mysql-8.0.11 –datadir=/data/db/–log-error=/data/db/mysql-error.log &

4.7 检查升级后mysql server版本:

$ cd /mysql/mysql-8.0.11

./bin/mysql -uroot -pmysql -S /data/db/mysql.sock

mysql> select version();

+———–+ | version() | +———–+ | 8.0.11 | +———–+ 1 row in set (0.00 sec)

–还应该检查日志文件,是否有错误出现。

到此,5.6.40 升级到 8.0.11全部完成。

– 此内容引用自https://zhuanlan.zhihu.com/p/39341418