Remember a small mysql version upgrade

When the recent back-end components for security scanning, found some minor flaw, in order to avoid problems after the security scan subsequent deployment, we decided to do a mysql version upgrade. Principle is to upgrade the mysql binary upgrade standby node if, after the completion of the upgrade to lift it from the node to upgrade the master node, then upgrade the original primary node.

Upgrade steps:

mysql Current Version: 5.7.24

Target version: 5.7.28

 

Preparation:

1. The installation package to be upgraded mysql: mysql-5.7.28-Linux-glibc2.12-x86_64.tar.gz , Download: https://dev.mysql.com/downloads/mysql/

 

 

 

 

 

 

 

 

 

 

 

 

 

2. Backup mysql data:

./mysqldump -u<ACCOUNT> -p<PASSWORD> -S mysql.sock -F -A -B |gzip > ~/mysql_backup/20191020/mysqlbak.sql.gz

3. Back up the configuration file:

cp <mysql-root>/*.cnf ~/mysql_backup/20191020/

 

Step (complete process includes preparing content):

 

1. Back up the database: 

mysqldump -u<username> -p<password> -S mysql.sock -F -A -B |gzip >/home/user/backup/20191029/mysqlbak.sql.gz

 

 

2. Stop the mysql database, my supervisor to do is to use process management, so execute commands directly:

supervisorctl stop mysql

tip: If you do not use the daemon use the following command to stop mysql:

mysql -u root -p -S /data/mysql3308/mysql3308.sock --execute="SET GLOBAL innodb_fast_shutdown=0"
mysqladmin -u root -p -S /data/mysql3308/mysql3308.sock shutdown

 

3. Back up the startup configuration files and startup scripts:

cp mysql / * .cnf / Home / the User / Backup / 20,191,029 / 
### startup script is to write for the supervisor, is not this a normal mysql 
cp mysql / bin / start.sh / home / user / backup / 20191029 /

 

4. Unpack the new version of the archive to the installation directory:

tar -zxvf mysql-5.7.28-linux-glibc2.12-x86_64.tar.gz -C <install-root>

 

5. Soft mysql connection point to the new version of the binary file

mv mysql mysql.20191029
ln -s <install-root>/mysql-5.7.28-linux-glibc2.12-x86_64 mysql

 

6. The backup startup configuration files and startup scripts to copy them to a new mysql:

cp /home/user/backup/20191029/*.cnf <install-root>/mysql/
cp /home/user/backup/20191029/bin/start.sh<install-root>/mysql/bin

 

7. Start mysql:

supervisorctl start mysql

 

8. Check all the tables are compatible with the current version, and update the system library (this version because the content is relatively small so the system libraries are compatible):

mysql_upgrade -u<user> -p<password> -S mysql.sock

 

9. Restart mysql, make changes to the system tables to take effect:

supervisorctl restart mysql

 

Guess you like

Origin www.cnblogs.com/JCYH/p/mysql_update.html