下面我尝试将 MySQL 5.7.44版本改成一个不存在的版本 MySQL 5.7.88版本,
可以正常启动数据库,检查版本确实变成了5.7.88。
MySQL 5.7分支最后一个版本就是5.7.44版本,所以根本不存在5.7.88版本。
1 | https: //downloads .mysql.com /archives/community/
|
测试过程如下:
注意:仅供参考,请勿在生产环境执行!
1.检查当前版本
1 2 3 4 5 6 7 8 | [mysql@cjc-db-01 ~]$ which mysql
/mysqldata/app/5 .7.44 /bin/mysql
[mysql@cjc-db-01 ~]$ which mysqld
/mysqldata/app/5 .7.44 /bin/mysqld
[mysql@cjc-db-01 ~]$ mysql -V
mysql Ver 14.14 Distrib 5.7.44, for el7 (x86_64) using EditLine wrapper
[mysql@cjc-db-01 ~]$ mysqld -V
mysqld Ver 5.7.44 for el7 on x86_64 (MySQL Community Server (GPL))
|
2.启动数据库
1 | [mysql@cjc-db-01 ~]$ mysqld --defaults- file = /etc/my .cnf --user=mysql &
|
3.通过命令检查版本
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | [mysql@cjc-db-01 ~]$ mysql -uroot -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 4
Server version: 5.7.44-log MySQL Community Server (GPL)
Copyright (c) 2000, 2023, 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> select version();
+------------+
| version() |
+------------+
| 5.7.44-log |
+------------+
1 row in set (0.00 sec)
|
4.停库
1 2 | mysql> shutdown ;
Query OK, 0 rows affected (0.00 sec)
|
5.备份mysqld文件
1 2 3 4 5 6 7 | [mysql@cjc-db-01 bin]$ pwd
/mysqldata/app/5 .7.44 /bin
[mysql@cjc-db-01 bin]$ cp mysqld mysqld_5744bak
[mysql@cjc-db-01 bin]$ ls -lrth mysqld*
....
-rwxr-xr-x 1 mysql mysql 241M Oct 11 2023 mysqld
-rwxr-xr-x 1 mysql mysql 241M Jan 3 21:08 mysqld_5744bak
|
检查mysqld文件中"5.7.44"关键字相关信息
1 2 3 4 5 6 7 8 | [mysql@cjc-db-01 bin]$ strings mysqld| grep -i 5.7.44| wc -l
5600
[mysql@cjc-db-01 bin]$ strings mysqld| grep -i 5.7.44| more
5.7.44
/var/lib/pb2/sb_1-12949965-1697025598 .1 /mysql-5 .7.44 /sql/mysqld .cc
/var/lib/pb2/sb_1-12949965-1697025598 .1 /mysql-5 .7.44 /sql/rpl_gtid .h
/var/lib/pb2/sb_1-12949965-1697025598 .1 /mysql-5 .7.44 /sql/binlog .h
....
|
6.利用 sed 修改替换 MySQL 版本号
1 2 3 4 5 6 7 | [mysql@cjc-db-01 bin]$ cd /mysqldata/app/5 .7.44 /bin
[mysql@cjc-db-01 bin]$ sed -i 's/5\.7\.44/5.7.88/ig' mysqld
[mysql@cjc-db-01 bin]$ strings mysqld| grep -i 5.7.88| more
5.7.88
/var/lib/pb2/sb_1-12949965-1697025598 .1 /mysql-5 .7.88 /sql/mysqld .cc
/var/lib/pb2/sb_1-12949965-1697025598 .1 /mysql-5 .7.88 /sql/rpl_gtid .h
/var/lib/pb2/sb_1-12949965-1697025598 .1 /mysql-5 .7.88 /sql/binlog .h
|
7.启动数据库
1 2 3 | [mysql@cjc-db-01 ~]$ mysqld --defaults- file = /etc/my .cnf --user=mysql &
[2] 8662
[1] Done mysqld --defaults- file = /etc/my .cnf --user=mysql
|
8.检查版本
检查日志,显示为mysqld 5.7.88-log。
1 2 3 4 | [mysql@cjc-db-01 log]$ tail -10f error.log
...
2025-01-03T21:14:55.154580+08:00 0 [Note] mysqld (mysqld 5.7.88-log) starting as process 8662 ...
...
|
mysql客户端还是5.7.44版本
1 2 | [mysql@cjc-db-01 ~]$ mysql -V
mysql Ver 14.14 Distrib 5.7.44, for el7 (x86_64) using EditLine wrapper
|
mysql服务端显示5.7.88版本
1 2 | [mysql@cjc-db-01 ~]$ mysqld -V
mysqld Ver 5.7.88 for el7 on x86_64 (MySQL Community Server (GPL))
|
登录数据库,执行命令,均显示5.7.88版本
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | [mysql@cjc-db-01 ~]$ mysql -uroot -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 3
Server version: 5.7.88-log MySQL Community Server (GPL)
Copyright (c) 2000, 2023, 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> select version();
+------------+
| version() |
+------------+
| 5.7.88-log |
+------------+
1 row in set (0.00 sec)
|
9.测试
可以正常新增和查询数据。
1 2 3 4 5 6 7 8 9 10 11 | mysql> create table cjc.t0103( id int,name varchar(10));
Query OK, 0 rows affected (0.31 sec)
mysql> insert into cjc.t0103 values(1, 'x' );
Query OK, 1 row affected (0.38 sec)
mysql> select * from cjc.t0103;
+------+------+
| id | name |
+------+------+
| 1 | x |
+------+------+
1 row in set (0.00 sec)
|
10.回退
1 2 3 4 5 6 7 8 9 | 停库
mysql> shutdown ;
[mysql@cjc-db-01 bin]$ pwd
/mysqldata/app/5 .7.44 /bin
回退
[mysql@cjc-db-01 bin]$ mv mysqld mysqld_5788bak
[mysql@cjc-db-01 bin]$ mv mysqld_5744bak mysqld
启动数据库
[mysql@cjc-db-01 bin]$ mysqld --defaults- file = /etc/my .cnf --user=mysql &
|