您的位置:首页 > 数据库 > MySQL

mysql 5.6 升级 mysql 5.7

2017-09-19 20:23 603 查看
mysql升级是个老生常谈的话题,不多说,主要记录mysql_update升级方式,以备给新手点借鉴

(一)注意点

1、磁盘空间是否充足,满足本机主从搭建;

2、mysql5.6中my.cnf的部分参数不在适用于5.7;

3、升级方式的选择

对于较小的库,利用mysqldump来直接导出sql文件,然后导入到新库中;

(二)升级步骤(mysql_update方式)

1、备份数据库,且备份恢复验证xtrabackup这里不详细记录

2、关闭当前5.6数据库实例

在关闭的时候刷新脏块

SET GLOBAL innodb_fast_shutdown=0

    ./mysql_start_5.6.sh 3308 stop

3、base目录修改为5.7对应

修改my.cnf  /data/server/mysql5.7-17

4、mysql_upgrade执行

/data/server/mysql5.7-17/bin/mysql_upgrade--defaults-file=/data/dbdata/my.cnf5.7 -h127.0.0.1 -uroot -p -P3308

(三)操作记录(10.88.100.15为例)

1、登陆并执行

SETGLOBAL innodb_fast_shutdown=0

2、停库 ./mysql_start.sh 3309 stop

3、下载5.7.17二进制包

下载  mysql-5.7.17-linux-glibc2.5-x86_64.tar.gz

 

tar–zxvf mysql-5.7.17-linux-glibc2.5-x86_64.tar.gz 

mv mysql-5.7.17-linux-glibc2.5-x86_64mysql-5.7.17

4、备份

  备份数据文件、redolog、共享表空间等

5、修改my.cnf

Basedir修改为/server/mysql-5.7.17

修改my.cnf中的innodb_use_sys_malloc=1 去掉

6、启动

/data-2/server/mysql-5.7.17/bin/mysqld_safe--defaults-file=/data-2/dbdata/data_3309/my.cnf --port=3309 --user=mysql>/dev/null 2>&1 &

6、升级数据文件

/data-2/server/mysql-5.7.17/bin/mysql_upgrade--defaults-file=/data-2/dbdata/data_3309/my.cnf -h127.0.0.1 -uJRJ_YongChao -p-P3309

7、关闭数据库

/data-2/server/mysql-5.7.17/bin/mysqladmin-h127.0.0.1 -P3309 -uJRJ_YongChao -p shutdown

8、修改mysql_start.sh 中mysqlbase基本目录为5.7.17 并启动

字符串替换

:1,$s/mysql-5.6.22/mysql-5.7.17/g

启动数据库

./mysql_start_5.7.sh3309 start

升级完成

(四)参考文档(官方文档-升级部分)

1.      Review the changesdescribed in Section 2.11.1.1,
“ChangesAffecting Upgrades to MySQL 5.7” for steps to be performed beforeupgrading.

2.      Configure MySQL toperform a slow shutdown by setting innodb_fast_shutdown to 0.
For example:

Press CTRL+C tocopy

mysql -u root -p --execute="SET GLOBALinnodb_fast_shutdown=0"

With a slowshutdown, InnoDB performs a full purge and change buffer merge beforeshutting down, which ensures that data files are fully prepared in case of fileformat differences between releases.

3.      Shut down the oldMySQL server. For example:

Press CTRL+C tocopy

mysqladmin -u root -p shutdown

4.      Upgrade the MySQLbinaries or packages in place (replace the old binaries or packages with thenew ones).

Note

Forsupported Linux distributions, the preferred method for replacing the MySQLpackages is to use the MySQL software repositories; see Section 2.11.1.2,
“UpgradingMySQL with the MySQL Yum Repository”, Section 2.11.1.3,
“UpgradingMySQL with the MySQL APT Repository”, or UpgradingMySQL with the MySQL SLES Repository for
instructions.

5.      Start the MySQL 5.7server, using the existing data directory. For example:

Press CTRL+C tocopy

mysqld_safe --user=mysql --datadir=/path/to/existing-datadir

6.      Run mysql_upgrade.
For example:

Press CTRL+C tocopy

mysql_upgrade -u root -p

mysql_upgrade examines
all tables in all databases forincompatibilities with the current version of MySQL. mysql_upgrade also
upgrades the mysql system database so that you can takeadvantage of new privileges or capabilities.

Note

mysql_upgrade should
not be used when the server is running with --gtid-mode=ON.
See GTIDmode and mysql_upgrade for
more information.

mysql_upgrade does
not upgrade the contents of the help tables. Forupgrade instructions, see Section 5.1.10,“Server-Side
Help”.

7.      Shut down andrestart the MySQL server to ensure that any changes made to the system tablestake effect. For example:

Press CTRL+C tocopy

mysqladmin -u root -p shutdown

mysqld_safe --user=mysql --datadir=/path/to/existing-datadir


 

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: