赞
踩
因漏洞扫描出以下结果(展示部分),推荐升级到5.7.38以上,索性直接升到头(小版本)。
Oracle MySQL 输入验证错误漏洞(CVE-2022-21454)
Oracle MySQL 输入验证错误漏洞(CVE-2022-21427)
因当时部署时用的rpm方式,所以这次也用rpm升级,官网看到5.7最高为40版本。
下载地址: https://cdn.mysql.com/archives/mysql-5.7/mysql-5.7.40-1.el7.x86_64.rpm-bundle.tar
下载完包后,开始备份文件(很重要!)
[root@db01 ~]# cp /etc/my.cnf /etc/my.cnf.bak
[root@db01 ~]# mysqldump -u root -p --set-gtid-purged=off --all-databases --single-transaction > /data01/backup/database20230308.sql
[root@db01 ~]# systemctl stop keepalived
登录mysql(从执行)
- mysql> stop slave;
- Query OK, 0 rows affected (0.01 sec)
[root@db01 ~]# systemctl stop mysqld
- [root@db01 ~]# rpm -qa|grep mysql
- mysql-community-common-5.7.38-1.el7.x86_64
- mysql-community-server-5.7.38-1.el7.x86_64
- mysql-community-libs-5.7.38-1.el7.x86_64
- mysql-community-client-5.7.38-1.el7.x86_64
这样不用先卸载再安装,数据库密码等配置也不会变,升级完后直接可以用原密码登录,否则还要用初始密码登录再改,slave等其他配置也得重新配。
- [root@db01 mysql]# rpm -Uvh mysql-community-server-5.7.40-1.el7.x86_64.rpm --force --nodeps
- warning: mysql-community-server-5.7.40-1.el7.x86_64.rpm: Header V4 RSA/SHA256 Signature, key ID 3a79bd29: NOKEY
- Preparing... ################################# [100%]
- Updating / installing...
- 1:mysql-community-server-5.7.40-1.e################################# [ 50%]
- Cleaning up / removing...
- 2:mysql-community-server-5.7.38-1.e################################# [100%]
- [root@db01 mysql]# rpm -Uvh mysql-community-libs-5.7.40-1.el7.x86_64.rpm --force --nodeps
- warning: mysql-community-libs-5.7.40-1.el7.x86_64.rpm: Header V4 RSA/SHA256 Signature, key ID 3a79bd29: NOKEY
- Preparing... ################################# [100%]
- Updating / installing...
- 1:mysql-community-libs-5.7.40-1.el7################################# [ 50%]
- Cleaning up / removing...
- 2:mysql-community-libs-5.7.38-1.el7################################# [100%]
- [root@db01 mysql]# rpm -Uvh mysql-community-common-5.7.40-1.el7.x86_64.rpm --force --nodeps
- warning: mysql-community-common-5.7.40-1.el7.x86_64.rpm: Header V4 RSA/SHA256 Signature, key ID 3a79bd29: NOKEY
- Preparing... ################################# [100%]
- Updating / installing...
- 1:mysql-community-common-5.7.40-1.e################################# [ 50%]
- Cleaning up / removing...
- 2:mysql-community-common-5.7.38-1.e################################# [100%]
- [root@db01 mysql]# rpm -Uvh mysql-community-client-5.7.40-1.el7.x86_64.rpm --force --nodeps
- warning: mysql-community-client-5.7.40-1.el7.x86_64.rpm: Header V4 RSA/SHA256 Signature, key ID 3a79bd29: NOKEY
- Preparing... ################################# [100%]
- Updating / installing...
- 1:mysql-community-client-5.7.40-1.e################################# [ 50%]
- Cleaning up / removing...
- 2:mysql-community-client-5.7.38-1.e################################# [100%]
升级完毕后确认下my.cnf文件,并且启动数据库。
[root@db01 mysql]# systemctl start mysqld.service
启动后登录数据库还用原来的密码。
- [root@db01 mysql]# mysql -uroot -p
- Enter password:
- Welcome to the MySQL monitor. Commands end with ; or \g.
- Your MySQL connection id is 6
- Server version: 5.7.40 MySQL Community Server (GPL)
-
- Copyright (c) 2000, 2022, Oracle and/or its affiliates.
-
- 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>
- [root@db01 mysql]# 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
- The sys schema is already up to date (version 1.5.2).
- Found 0 sys functions, but expected 22. Re-installing the sys schema.
- Upgrading the sys schema.
- Checking databases.
- sys.sys_config OK
- Upgrade process completed successfully.
- Checking if update is needed.
- [root@db01 mysql]# mysql -V
- mysql Ver 14.14 Distrib 5.7.40, for Linux (x86_64) using EditLine wrapper
- mysql> start slave;
- Query OK, 0 rows affected (0.01 sec)
mysql> show slave status \G
主创建一个test,验证在从上是否能看到。
- mysql> create database test;
- Query OK, 1 row affected (0.00 sec)
-
- mysql> show databases;
- +--------------------+
- | Database |
- +--------------------+
- | information_schema |
- | mysql |
- | performance_schema |
- | sys |
- | test |
- +--------------------+
- 5 rows in set (0.00 sec)
-
[root@db01 mysql]# systemctl start keepalived
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。