首页 > 代码库 > MySQL升级从5.6.18到5.7.11
MySQL升级从5.6.18到5.7.11
rhel7.2上升级MySQL5.6.18到5.7.11
本次使用二进制包采用out-place方式进行升级。
1、备份数据
备份重于一切!
各种备份方法mysqldump、cp.....
2、上传5.7.11软件包并解压
[root@rhel7 mysql]# ls mysql5.6.18 mysql-5.7.11-linux-glibc2.5-x86_64.tar.gz [root@rhel7 mysql]# tar -zxvf mysql-5.7.11-linux-glibc2.5-x86_64.tar.gz ...... [root@rhel7 mysql]# mv mysql-5.7.11-linux-glibc2.5-x86_64 mysql5.7.11
[root@rhel7 mysql]# chown mysql:mysql -R mysql5.7.11
[root@rhel7 mysql]# ls -l
total 8
drwxr-xr-x. 13 mysql mysql 4096 Dec 5 15:17 mysql5.6.18
drwxr-xr-x. 9 mysql mysql 4096 Feb 2 2016 mysql5.7.11
3、停止旧版本数据库
#设置innodb_fast_shutdown=0 [root@rhel7 bin]# pwd /opt/mysql/mysql5.6.18/bin [root@rhel7 bin]# ./mysql -u root -p --execute="SET GLOBAL innodb_fast_shutdown=0" Enter password: [root@rhel7 bin]# ./mysql -u root -p --execute="show global variables like ‘innodb_fast_shutdown‘" Enter password: +----------------------+-------+ | Variable_name | Value | +----------------------+-------+ | innodb_fast_shutdown | 0 | +----------------------+-------+ #关闭MySQL [root@rhel7 bin]# ./mysqladmin -uroot -p shutdown Enter password: [root@rhel7 bin]# ps -ef |grep mysql root 2771 1575 0 16:58 pts/0 00:00:00 grep --color=auto mysql
innodb_fast_shutdown参数解释参考:http://dev.mysql.com/doc/refman/5.7/en/innodb-parameters.html#sysvar_innodb_fast_shutdown
4、修改配置文件
#修改/etc/my.cnf文件 [root@rhel7 bin]# vi /etc/my.cnf basedir = /opt/mysql/mysql5.7.11 #basedir指向新的软件目录
5、启动新版本软件
[root@rhel7 mysql5.7.11]# pwd /opt/mysql/mysql5.7.11 [root@rhel7 mysql5.7.11]# ./bin/mysqld_safe --user=mysql & [1] 3000 [root@rhel7 mysql5.7.11]# 2016-12-05T09:03:09.133964Z mysqld_safe Logging to ‘/mysqldata/rhel7.err‘. 2016-12-05T09:03:09.161910Z mysqld_safe Starting mysqld daemon with databases from /mysqldata [root@rhel7 mysql5.7.11]# ps -ef |grep mysql root 3000 1575 0 17:03 pts/0 00:00:00 /bin/sh ./bin/mysqld_safe --user=mysql mysql 3118 3000 3 17:03 pts/0 00:00:00 /opt/mysql/mysql5.7.11/bin/mysqld --basedir=/opt/mysql/mysql5.7.11 --datadir=/mysqldata --plugin-dir=/opt/mysql/mysql5.7.11/lib/plugin --user=mysql --log-error=/m ysqldata/rhel7.err --pid-file=/mysqldata/rhel7.pidroot 3147 1575 0 17:03 pts/0 00:00:00 grep --color=auto mysql
6、升级数据库
[root@rhel7 mysql5.7.11]# ./bin/mysql_upgrade -uroot -p Enter password: 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.func OK mysql.general_log OK mysql.gtid_executed OK mysql.help_category OK mysql.help_keyword OK mysql.help_relation OK mysql.help_topic OK mysql.innodb_index_stats OK mysql.innodb_table_stats OK mysql.ndb_binlog_index OK mysql.plugin OK mysql.proc OK mysql.procs_priv OK mysql.proxies_priv OK mysql.server_cost OK mysql.servers OK mysql.slave_master_info OK mysql.slave_relay_log_info OK mysql.slave_worker_info OK mysql.slow_log OK mysql.tables_priv OK mysql.time_zone OK mysql.time_zone_leap_second OK mysql.time_zone_name OK mysql.time_zone_transition OK mysql.time_zone_transition_type OK mysql.user OK Upgrading the sys schema. Checking databases. sys.sys_config OK test.t_nu OK test.u OK Upgrade process completed successfully. Checking if update is needed.
7、重启MySQL以保证所有升级应用成功
[root@rhel7 mysql5.7.11]# ./bin/mysqladmin -uroot -p123456 shutdown mysqladmin: [Warning] Using a password on the command line interface can be insecure. [root@rhel7 mysql5.7.11]# 2016-12-05T09:09:39.211113Z mysqld_safe mysqld from pid file /mysqldata/rhel7.pid ended [1]+ Done ./bin/mysqld_safe --user=mysql [root@rhel7 mysql5.7.11]# ps -ef |grep mysql root 3162 1575 0 17:09 pts/0 00:00:00 grep --color=auto mysql [root@rhel7 mysql5.7.11]# ./bin/mysqld_safe --user=mysql & [1] 3163 [root@rhel7 mysql5.7.11]# 2016-12-05T09:10:02.064621Z mysqld_safe Logging to ‘/mysqldata/rhel7.err‘. 2016-12-05T09:10:02.097210Z mysqld_safe Starting mysqld daemon with databases from /mysqldata [root@rhel7 mysql5.7.11]# ps -ef |grep mysql root 3163 1575 0 17:10 pts/0 00:00:00 /bin/sh ./bin/mysqld_safe --user=mysql mysql 3287 3163 2 17:10 pts/0 00:00:00 /opt/mysql/mysql5.7.11/bin/mysqld --basedir=/opt/mysql/mysql5.7.11 --datadir=/mysqldata --plugin-dir=/opt/mysql/mysql5.7.11/lib/plugin --user=mysql --log-error=/m ysqldata/rhel7.err --pid-file=/mysqldata/rhel7.pidroot 3316 1575 0 17:10 pts/0 00:00:00 grep --color=auto mysql [root@rhel7 mysql5.7.11]# ./bin/mysql -uroot -p123456 mysql: [Warning] Using a password on the command line interface can be insecure. Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 2 Server version: 5.7.11 MySQL Community Server (GPL) Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners. Type ‘help;‘ or ‘\h‘ for help. Type ‘\c‘ to clear the current input statement. mysql> show status; +-----------------------------------------------+--------------------------------------------------+ | Variable_name | Value | +-----------------------------------------------+--------------------------------------------------+ | Aborted_clients | 0 | | Aborted_connects | 0 | | Binlog_cache_disk_use | 0 | | Binlog_cache_use | 0 | | Binlog_stmt_cache_disk_use | 0 | | Binlog_stmt_cache_use | 0 | | Bytes_received | 248 | ......
如果不重启可能会报如下错误:
mysql> show status; ERROR 1682 (HY000): Native table ‘performance_schema‘.‘session_status‘ has the wrong structure
官方文档:http://dev.mysql.com/doc/refman/5.7/en/upgrading.html#upgrade-procedure-inplace
本文出自 “DBA Fighting!” 博客,请务必保留此出处http://hbxztc.blog.51cto.com/1587495/1879904
MySQL升级从5.6.18到5.7.11
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。