mysql升级是个老生常谈的话题,不多说,主要记录mysql_update升级方式,以备给新手点借鉴
对于较小的库,利用mysqldump来直接导出sql文件,然后导入到新库中;
在关闭的时候刷新脏块
SET GLOBAL innodb_fast_shutdown=0
./mysql_start_5.6.sh 3308 stop
修改my.cnf /data/server/mysql5.7-17
/data/server/mysql5.7-17/bin/mysql_upgrade--defaults-file=/data/dbdata/my.cnf5.7 -h127.0.0.1 -uroot -p -P3308
SETGLOBAL innodb_fast_shutdown=0
下载 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
备份数据文件、redolog、共享表空间等
Basedir修改为/server/mysql-5.7.17
修改my.cnf中的innodb_use_sys_malloc=1 去掉
/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 &
/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
/data-2/server/mysql-5.7.17/bin/mysqladmin-h127.0.0.1 -P3309 -uJRJ_YongChao -p shutdown
字符串替换
: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