暂无图片
暂无图片
暂无图片
暂无图片
暂无图片

mysql小版本升级(5.7.25-5.7.30)

原创 李佳豪 云和恩墨 2021-05-10
4552

mysql小版本升级(5.7.25-5.7.30)
需求:从 5.7.25 升级为 5.7.30
查看当前 MySQL 版本:

select version();
+------------+
| version()  |
+------------+
| 5.7.25-log |
+------------+
1 row in set (0.00 sec)

1 下载要升级的软件包
首先从官网下载升级的二进制版本包上传到服务器:

[root@db01 ~]# ll
total 745512
-rw-r--r--. 1 root root 660017902 Apr 23 23:29 mysql-5.7.30-linux-glibc2.12-x86_64.tar.gz

2 备份数据库
按照自己需求备份数据和配置文件:

mysqldump -uroot -p123456 -A > /root/full_bak_20210510.sql

3 停止 MySQL 服务

mysqladmin -u root -p shutdown

4 替换新版本软件包
解压下载的二进制安装包,覆盖原来的安装路径:
备份原MySQL程序

[root@db01 /]# mkdir  /application_bak_525
[root@db01 ~]# cd /application
[root@db01 application]# mv * /application_bak_525/

解压缩软件包

[root@db01 ~]# tar -zxvf mysql-5.7.30-linux-glibc2.12-x86_64.tar.gz -C /application

[root@db01 application]# ll
total 0
drwxr-xr-x. 9 root root 129 May 10 11:45 mysql-5.7.30-linux-glibc2.12-x86_64

修改MySQL文件名

[root@db01 application]# mv mysql-5.7.30-linux-glibc2.12-x86_64/ mysql
[root@db01 application]# ll
total 0
drwxr-xr-x. 9 root root 129 May 10 11:45 mysql

查看MySQL版本

[root@db01 application]# mysql -V
mysql  Ver 14.14 Distrib 5.7.30, for linux-glibc2.12 (x86_64) using  EditLine wrapper

5 启动新版本MySQL
使用现有的目录启动 MySQL 服务:

[root@db01 bin]# /application/mysql/bin/mysqld_safe --defaults-file=/etc/my.cnf --datadir=/data/mysql/data --user=mysql &
[1] 5293
[root@db01 bin]# 2021-05-10T03:48:11.648889Z mysqld_safe Logging to '/data/mysql/data/db01.err'.
2021-05-10T03:48:11.675320Z mysqld_safe Starting mysqld daemon with databases from /data/mysql/data

[root@db01 bin]# 
[root@db01 bin]# ps -ef|grep mysql
root       5293   4866  0 11:48 pts/0    00:00:00 /bin/sh /application/mysql/bin/mysqld_safe --defaults-file=/etc/my.cnf --datadir=/data/mysql/data --user=mysql
mysql      5581   5293  9 11:48 pts/0    00:00:01 /application/mysql/bin/mysqld --defaults-file=/etc/my.cnf --basedir=/application/mysql/ --datadir=/data/mysql/data --plugin-dir=/application/mysql//lib/plugin --user=mysql --log-error=db01.err --pid-file=db01.pid --socket=/tmp/mysql.sock --port=3306
root       5610   4866  0 11:48 pts/0    00:00:00 grep --color=auto mysql

6 运行MySQL升级程序
运行 mysql_upgrade:

mysql_upgrade -u root -p
[root@db01 bin]# mysql_upgrade -u root -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
Found outdated sys schema version 1.5.1.
Upgrading the sys schema.
Checking databases.
sys.sys_config                                     OK
test.t                                             OK
test.t100w                                         OK
Upgrade process completed successfully.
Checking if update is needed.

7 重启MySQL
关闭 MySQL 重新启动:

mysqladmin -u root -p shutdown

[root@db01 bin]# mysqld_safe --defaults-file=/etc/my.cnf --user=mysql &
[1] 5620
[root@db01 bin]# 2021-05-10T03:49:25.329701Z mysqld_safe Logging to '/data/mysql/data/db01.err'.
2021-05-10T03:49:25.360550Z mysqld_safe Starting mysqld daemon with databases from /data/mysql/data

8 登录数据库查看版本
登陆到 MySQL 查询版本:

[root@db01 bin]# mysql -uroot -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.7.30-log MySQL Community Server (GPL)

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

db01 [(none)]>select version();
+------------+
| version()  |
+------------+
| 5.7.30-log |
+------------+
1 row in set (0.00 sec)

db01 [(none)]>show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| sys                |
| test               |
+--------------------+
5 rows in set (0.00 sec)

db01 [(none)]>use test
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
db01 [test]>show tables;
+----------------+
| Tables_in_test |
+----------------+
| t              |
| t100w          |
+----------------+
2 rows in set (0.00 sec)
「喜欢这篇文章,您的关注和赞赏是给作者最好的鼓励」
关注作者
【版权声明】本文为墨天轮用户原创内容,转载时必须标注文章的来源(墨天轮),文章链接,文章作者等基本信息,否则作者和墨天轮有权追究责任。如果您发现墨天轮中有涉嫌抄袭或者侵权的内容,欢迎发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。

评论