MySQL升级从5.6.18到5.7.11
rhel7.2上升级MySQL5.6.18到5.7.11本次使用二进制包采用out-place方式进行升级。
1、备份数据
备份重于一切!
各种备份方法mysqldump、cp.....
2、上传5.7.11软件包并解压
1
2
3
4
5
# ls
mysql5.6.18mysql-5.7.11-linux-glibc2.5-x86_64.tar.gz
# tar -zxvf mysql-5.7.11-linux-glibc2.5-x86_64.tar.gz
......
# mv mysql-5.7.11-linux-glibc2.5-x86_64 mysql5.7.11
# chown mysql:mysql -R mysql5.7.11
# ls -l
total 8
drwxr-xr-x. 13 mysql mysql 4096 Dec5 15:17 mysql5.6.18
drwxr-xr-x.9 mysql mysql 4096 Feb22016 mysql5.7.11
3、停止旧版本数据库
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#设置innodb_fast_shutdown=0
# pwd
/opt/mysql/mysql5.6.18/bin
# ./mysql -u root -p --execute="SET GLOBAL innodb_fast_shutdown=0"
Enter password:
# ./mysql -u root -p --execute="show global variables like 'innodb_fast_shutdown'"
Enter password:
+----------------------+-------+
| Variable_name | Value |
+----------------------+-------+
| innodb_fast_shutdown | 0 |
+----------------------+-------+
#关闭MySQL
# ./mysqladmin -uroot -p shutdown
Enter password:
# ps -ef |grep mysql
root 277115750 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、修改配置文件
1
2
3
#修改/etc/my.cnf文件
# vi /etc/my.cnf
basedir = /opt/mysql/mysql5.7.11 #basedir指向新的软件目录
5、启动新版本软件
1
2
3
4
5
6
7
8
9
10
11
# pwd
/opt/mysql/mysql5.7.11
# ./bin/mysqld_safe --user=mysql &
3000
# 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
# ps -ef |grep mysql
root 300015750 17:03 pts/0 00:00:00 /bin/sh ./bin/mysqld_safe --user=mysql
mysql 311830003 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 314715750 17:03 pts/0 00:00:00 grep --color=auto mysql
6、升级数据库
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# ./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以保证所有升级应用成功
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# ./bin/mysqladmin -uroot -p123456 shutdown
mysqladmin: Using a password on the command line interface can be insecure.
# 2016-12-05T09:09:39.211113Z mysqld_safe mysqld from pid file /mysqldata/rhel7.pid ended
+Done ./bin/mysqld_safe --user=mysql
# ps -ef |grep mysql
root 316215750 17:09 pts/0 00:00:00 grep --color=auto mysql
# ./bin/mysqld_safe --user=mysql &
3163
# 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
# ps -ef |grep mysql
root 316315750 17:10 pts/0 00:00:00 /bin/sh ./bin/mysqld_safe --user=mysql
mysql 328731632 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 331615750 17:10 pts/0 00:00:00 grep --color=auto mysql
# ./bin/mysql -uroot -p123456
mysql: 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 |
......
如果不重启可能会报如下错误:
1
2
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
页:
[1]