mysql8升级测试

参考文档:https://mysql.net.cn/doc/refman/8.0/en/mysql-upgrade.html

mysql5.7包: mysql-5.7.25-linux-glibc2.12-x86_64         << mysql8包: mysql-8.0.35-linux-glibc2.28-x86_64.tar.xz    <<< glibc2.28 ,这个包,需要升级gcc,最终没有使用这个包
mysql8包:mysql-8.0.35-linux-glibc2.12-x86_64.tar.xz     <<< 最终使用这个包 
  

-- 创建mysql5.7的文件夹

[mysql@19ctest mysql]$ mkdir -p mysql_upgrade_test/mysql7000
[mysql@19ctest mysql]$ cd mysql_upgrade_test/mysql7000
[mysql@19ctest mysql_upgrade_test]$ pwd
/mysql/mysql_upgrade_test/mysql7000
[mysql@19ctest mysql_upgrade_test]$

--安装mysql5.7,copy安装文件到指定的目录

[mysql@19ctest mysql-5.7.25-linux-glibc2.12-x86_64]$ cp -r * /mysql/mysql_upgrade_test/mysql7000/
[mysql@19ctest mysql-5.7.25-linux-glibc2.12-x86_64]$

-- 编辑my7000.cnf文件

vi /mysql/mysql_upgrade_test/mysql7000/my7000.cnf
[mysqld]
datadir=/mysql/mysql_upgrade_test/mysql7000/data
socket=/mysql/mysql_upgrade_test/mysql7000/mysql7000.sock
port=7000
basedir=/mysql/mysql_upgrade_test/mysql7000
server-id=7000
lc-messages-dir=/mysql/mysql_upgrade_test/mysql7000/share/english
[client]
port=7000
socket=/mysql/mysql_upgrade_test/mysql7000/mysql7000.sock
[mysql]
prompt="\u@db \R:\m:\s [\d]> "

-- 进行初始化mysql5.7 .会生成初始化的密码 

cd /mysql/mysql_upgrade_test/mysql7000/bin
./mysqld  --defaults-file=/mysql/mysql_upgrade_test/mysql7000/my7000.cnf  --initialize  --user=mysql 

[mysql@19ctest bin]$ ./mysqld  --defaults-file=/mysql/mysql_upgrade_test/mysql7000/my7000.cnf  --initialize  --user=mysql
2023-12-16T00:59:37.088284Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2023-12-16T00:59:37.425015Z 0 [Warning] InnoDB: New log files created, LSN=45790
2023-12-16T00:59:37.488073Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.
2023-12-16T00:59:37.545716Z 0 [Warning] No existing UUID has been found, so we assume that this is the first time that this server has been started. Generating a new UUID: 6292a606-9bae-11ee-958f-000c290cfd81.
2023-12-16T00:59:37.548191Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.
2023-12-16T00:59:37.550658Z 1 [Note] A temporary password is generated for root@localhost: *eJr:Barb7cq
[mysql@19ctest bin]$

--启动mysql5.7 

./mysqld_safe --defaults-file=/mysql/mysql_upgrade_test/mysql7000/my7000.cnf --user=mysql &   

[mysql@19ctest bin]$ pwd
/mysql/mysql_upgrade_test/mysql7000/bin
[mysql@19ctest bin]$ ./mysqld_safe --defaults-file=/mysql/mysql_upgrade_test/mysql7000/my7000.cnf --user=mysql &
[1] 4731
[mysql@19ctest bin]$ 2023-12-16T01:27:33.821921Z mysqld_safe Logging to '/mysql/mysql_upgrade_test/mysql7000/data/19ctest.err'.
2023-12-16T01:27:33.873417Z mysqld_safe Starting mysqld daemon with databases from /mysql/mysql_upgrade_test/mysql7000/data

[mysql@19ctest bin]$

-- 登录MySQL5.7 ,修改密码 

[mysql@19ctest bin]$ ./mysql -uroot -hlocalhost -p*eJr:Barb7cq -P7000 -S /mysql/mysql_upgrade_test/mysql7000/mysql7000.sock
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.25

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

root@db 09:36:11 [(none)]>
root@db 09:36:11 [(none)]> alter user 'root'@'localhost' identified by 'mysql';
Query OK, 0 rows affected (0.00 sec)

root@db 09:38:46 [(none)]>

[mysql@19ctest bin]$ ./mysql -uroot -hlocalhost -p -P7000 -S /mysql/mysql_upgrade_test/mysql7000/mysql7000.sock
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 3
Server version: 5.7.25 MySQL Community Server (GPL)

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

root@db 09:39:12 [(none)]>

-- 解压mysql8 

[mysql@19ctest mysql_upgrade_test]$ tar -xvf mysql-8.0.35-linux-glibc2.12-x86_64.tar.xz
[mysql@19ctest mysql_upgrade_test]$ mv mysql-8.0.35-linux-glibc2.12-x86_64 mysql8000
[mysql@19ctest mysql_upgrade_test]$ ls -l
total 448912
drwxr-xr-x 10 mysql mysql      4096 Dec 16 09:42 mysql7000
drwxrwxr-x  9 mysql mysql       129 Dec 16 09:44 mysql8000
-rw-rw-r--  1 mysql mysql 459678820 Dec 16 09:42 mysql-8.0.35-linux-glibc2.12-x86_64.tar.xz
[mysql@19ctest mysql_upgrade_test]$

-- 编辑mysql8的cnf文件

[mysql@19ctest mysql8000]$ more my8000.cnf
[mysqld]
datadir=/mysql/mysql_upgrade_test/mysql7000/data
socket=/mysql/mysql_upgrade_test/mysql7000/mysql7000.sock
port=7000
basedir=/mysql/mysql_upgrade_test/mysql8000
server-id=7000
plugin_dir=/mysql/mysql_upgrade_test/mysql8000/lib/plugin
lc-messages-dir=/mysql/mysql_upgrade_test/mysql8000/share/english

[client]
port=7000
socket=/mysql/mysql_upgrade_test/mysql7000/mysql7000.sock
[mysql]
prompt="\u@db \R:\m:\s [\d]> "

[mysql@19ctest mysql8000]$

-- 进行升级,进入到MySQL8的目录,执行升级

[mysql@19ctest mysql_upgrade_test]$ cd mysql8000/
[mysql@19ctest mysql8000]$ cd bin
[mysql@19ctest bin]$

./mysql_upgrade -uroot -hlocalhost -p -P7000 -S /mysql/mysql_upgrade_test/mysql7000/mysql7000.sock

-- mysql8.0.16开始,升级变了。

[mysql@19ctest bin]$ ./mysql_upgrade -uroot -hlocalhost -p -P7000 -S /mysql/mysql_upgrade_test/mysql7000/mysql7000.sock
The mysql_upgrade client is now deprecated. The actions executed by the upgrade client are now done by the server.
To upgrade, please start the new MySQL binary with the older data directory. Repairing user tables is done automatically. Restart is not required after upgrade.
The upgrade process automatically starts on running a new MySQL binary with an older data directory. To avoid accidental upgrades, please use the --upgrade=NONE option with the MySQL binary. The option --upgrade=FORCE is also provided to run the server upgrade sequence on demand.
It may be possible that the server upgrade fails due to a number of reasons. In that case, the upgrade sequence will run again during the next MySQL server start. If the server upgrade fails repeatedly, the server can be started with the --upgrade=MINIMAL option to start the server without executing the upgrade sequence, thus allowing users to manually rectify the problem.
[mysql@19ctest bin]$

-- 关闭mysql5.7,使用MySQL8启动数据库并升级

[mysql@19ctest bin]$ ./mysqladmin -uroot -hlocalhost -p -P7000 -S /mysql/mysql_upgrade_test/mysql7000/mysql7000.sock shutdown
Enter password:
[mysql@19ctest bin]$

-- 启动mysql8 并升级

cd mysql/mysql_upgrade_test/mysql8000/bin
./mysqld --defaults-file=/mysql/mysql_upgrade_test/mysql7000/my7000.cnf --user=mysql --upgrade=auto


[mysql@19ctest bin]$ ./mysqld --defaults-file=/mysql/mysql_upgrade_test/mysql7000/my7000.cnf --user=mysql --upgrade=auto
mysqld: Can't open shared library '/mysql/mysql_upgrade_test/mysql7000/lib/plugin/component_reference_cache.so' (errno: 0 /mysql/mysql_upgrade_test/mysql7000/lib/plugin/component_reference_cache.so: cannot open shared object file: No such file or dir)
mysqld: Cannot load component from specified URN: 'file://component_reference_cache'.
2023-12-16T03:02:35.149213Z 0 [System] [MY-010116] [Server] /mysql/mysql_upgrade_test/mysql8000/bin/mysqld (mysqld 8.0.35) starting as process 13303
2023-12-16T03:02:35.167658Z 0 [ERROR] [MY-010340] [Server] Error message file '/mysql/mysql_upgrade_test/mysql7000/share/english/errmsg.sys' had only 1116 error messages, but it should contain at least 5862 error messages. Check that the above file is the right version for this program!
2023-12-16T03:02:35.191241Z 1 [System] [MY-011012] [Server] Starting upgrade of data directory.
2023-12-16T03:02:35.191338Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started.
2023-12-16T03:02:36.816575Z 1 [System] [MY-013577] [InnoDB] InnoDB initialization has ended.
2023-12-16T03:02:38.587220Z 2 [System] [MY-011003] [Server] Finished populating Data Dictionary tables with data.
2023-12-16T03:02:39.360123Z 5 [System] [MY-013381] [Server] Server upgrade from '50700' to '80035' started.
2023-12-16T03:02:43.514651Z 5 [System] [MY-013381] [Server] Server upgrade from '50700' to '80035' completed.
2023-12-16T03:02:43.777130Z 0 [Warning] [MY-013829] [Server] Missing data directory for ICU regular expressions: /mysql/mysql_upgrade_test/mysql7000/lib/private/.
2023-12-16T03:02:45.099229Z 0 [Warning] [MY-010068] [Server] CA certificate ca.pem is self signed.
2023-12-16T03:02:45.099309Z 0 [System] [MY-013602] [Server] Channel mysql_main configured to support TLS. Encrypted connections are now supported for this channel.
2023-12-16T03:02:45.360171Z 0 [System] [MY-010931] [Server] /mysql/mysql_upgrade_test/mysql8000/bin/mysqld: ready for connections. Version: '8.0.35'  socket: '/mysql/mysql_upgrade_test/mysql7000/mysql7000.sock'  port: 7000  MySQL Community Server - GPL.
2023-12-16T03:02:45.360272Z 0 [System] [MY-011323] [Server] X Plugin ready for connections. Bind-address: '::' port: 33060, socket: /tmp/mysqlx.sock

-- 问题1 ,找不到component_reference_cache.so,查看mysql5.7,里面没有这个文件,mysql8,有这个文件

[mysql@19ctest plugin]$ ls -l component_reference_cache.so
ls: cannot access component_reference_cache.so: No such file or directory
[mysql@19ctest plugin]$ pwd
/mysql/mysql_upgrade_test/mysql7000/lib/plugin
[mysql@19ctest plugin]$
[mysql@19ctest lib]$ cd plugin/
[mysql@19ctest plugin]$ ls -l component_reference_cache.so
-rwxr-xr-x 1 mysql mysql 89272 Oct 13 00:27 component_reference_cache.so
[mysql@19ctest plugin]$ pwd
/mysql/mysql_upgrade_test/mysql8000/lib/plugin
[mysql@19ctest plugin]$

解决方法:修改mysql8的cof文件,添加plugin_dir
plugin_dir=/mysql/mysql_upgrade_test/mysql8000/lib/plugin


--再次启动mysql 8,进行升级 

[mysql@19ctest bin]$ ./mysqld --defaults-file=/mysql/mysql_upgrade_test/mysql8000/my8000.cnf --user=mysql --upgrade=auto
2023-12-16T05:13:03.039494Z 0 [System] [MY-010116] [Server] /mysql/mysql_upgrade_test/mysql8000/bin/mysqld (mysqld 8.0.35) starting as process 4981
2023-12-16T05:13:03.041250Z 0 [Warning] [MY-010339] [Server] Using pre 5.5 semantics to load error messages from /mysql/mysql_upgrade_test/mysql8000/share/english/. If this is not intended, refer to the documentation for valid usage of --lc-messages-dir and --language parameters.
2023-12-16T05:13:03.052260Z 1 [System] [MY-011012] [Server] Starting upgrade of data directory.
2023-12-16T05:13:03.052295Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started.
2023-12-16T05:13:04.267690Z 1 [System] [MY-013577] [InnoDB] InnoDB initialization has ended.
2023-12-16T05:13:05.266337Z 2 [System] [MY-011003] [Server] Finished populating Data Dictionary tables with data.
2023-12-16T05:13:05.866598Z 5 [System] [MY-013381] [Server] Server upgrade from '50700' to '80035' started.
2023-12-16T05:13:09.623950Z 5 [System] [MY-013381] [Server] Server upgrade from '50700' to '80035' completed.
2023-12-16T05:13:11.785012Z 0 [Warning] [MY-010068] [Server] CA certificate ca.pem is self signed.
2023-12-16T05:13:11.785080Z 0 [System] [MY-013602] [Server] Channel mysql_main configured to support TLS. Encrypted connections are now supported for this channel.
2023-12-16T05:13:12.352943Z 0 [System] [MY-010931] [Server] /mysql/mysql_upgrade_test/mysql8000/bin/mysqld: ready for connections. Version: '8.0.35'  socket: '/mysql/mysql_upgrade_test/mysql7000/mysql7000.sock'  port: 7000  MySQL Community Server - GPL.
2023-12-16T05:13:12.353089Z 0 [System] [MY-011323] [Server] X Plugin ready for connections. Bind-address: '::' port: 33060, socket: /tmp/mysqlx.sock

-- 升级完成,登录MySQL8 .正常

./mysqladmin -uroot -hlocalhost -p -P7000 -S /mysql/mysql_upgrade_test/mysql7000/mysql7000.sock shutdown 
./mysqld_safe --defaults-file=/mysql/mysql_upgrade_test/mysql8000/my8000.cnf --user=mysql &

./mysql -uroot -hlocalhost -p -P7000 -S /mysql/mysql_upgrade_test/mysql7000/mysql7000.sock

END

你可能感兴趣的:(MySQL,数据库)