广告联盟网

标题: mysql5.6升级到5.7的注意事项 [打印本页]

作者: ggads    时间: 2021-8-11
标题: mysql5.6升级到5.7的注意事项
mysql5.6 升级至 mysql5.7

环境介绍:
旧库:
basedir=/usr/local/mysql-5.6
datadir=/home/mysql
config=/home/mysql/my.cnf
sock=/home/mysql/mysql.sock
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
character_set_server = utf8
lower_case_table_names=1
skip-host-cache
skip-name-resolve
federated
log-error=/home/mysql/log/mysqld.log
pid-file=/home/mysql/master.example.com.pid

[mysql]
default-character-set = utf8
socket=/home/mysql/mysql.sock


升级步骤:

1、对mysql5.6进行全库备份(******)用于失败倒回
2、关闭mysql5.6版本数据库
3、将mysql5.7软件部署
4、修改配置信息
5、修改启动脚本
6、启动mysql5.7数据库
7、mysql_upgrade升级数据库相关参数
8、重启数据库,测试升级结果

1、全库备份
mysqldump -uroot -p123456 --all-databases > /root/mysql_all.sql


2、 关闭数据库

/usr/local/mysql-5.6/bin/mysqladmin -uroot -p123456 shutdown

验证
netstat -tnpl|grep :3306

3、 部署mysql5.7
tar xf mysql-5.7.22-el7-x86_64.tar.gz -C /usr/local

cd /usr/local
mv mysql-5.7.22 mysql5.7

4、修改配置信息

vim /home/mysql/my.cnf
basedir=/usr/local/mysql5.7            ---修改

5、修改启动脚本
cp /usr/local/mysql5.7/support-files/mysql.server /etc/init.d/mysql5.7

vim /etc/init.d/mysql5.7
basedir=/usr/local/mysql5.7
datadir=/home/mysql

6、启动mysql5.7
service mysql5.7 start

[root@master ~]# netstat -tnpl |grep :3306
tcp6       0      0 :::3306                 :::*                    LISTEN      8820/mysqld

[root@master mysql]# 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.22 MySQL Community Server (GPL)

Copyright (c) 2000, 2018, 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.


7、mysql_upgrade升级数据库相关参数
mysql_upgrade -uroot -p123456
mysql> select user,host, authentication_string from mysql.user;
+---------------+--------------------+-------------------------------------------+
| user          | host               | authentication_string                     |
+---------------+--------------------+-------------------------------------------+
| root          | localhost          | *6BB4837EB74329105EE4568DDA7DC67ED2CA2AD9 |
| root          | master.example.com |                                           |
| root          | 127.0.0.1          |                                           |


测试升级成功






欢迎光临 广告联盟网 (https://bbs.ggads.com/) Powered by Discuz! X3.2