MySQL 8.0 General Availability was announced in April and it comes with a host of new features. The overview about the new features and improvements made in MySQL 8.0 can be found in the following blog.
The server can be upgraded by performing either an INPLACE upgrade or LOGICAL upgrade. The INPLACE upgrade involves shutting down the MySQL 5.7 server, replacing the old binaries with MySQL 8.0 binaries and then starting the MySQL 8.0 server on the old data directory. The LOGICAL upgrade involves exporting SQL from the MySQL 5.7 version using a backup or export utility such as mysqldump or mysqlpump, installing the MySQL 8.0 binaries, and then applying the SQL to the new MySQL version.
The INPLACE upgrade is faster than the LOGICAL upgrade since it does not require loading of the databases after installing MySQL 8.0 version. Also while loading the databases during LOGICAL upgrade, errors might be encountered due to the incompatibilities which would require modifying the exported SQL file.
This blog post describes the simple steps to be followed for performing an INPLACE upgrade to MySQL 8.0.
- The first step in upgrading to MySQL 8.0 is checking the upgrade preparedness of the existing MySQL 5.7 server. We wanted this process to be simple for users and hence introduced a Upgrade Checker utility that comes with the MySQL Shell 8.0. The blog on Upgrade Checker describes how simple it is to run the utility and check if there are any actions that needs to be taken prior to upgrade. Let me run the utility against a running MySQL 5.7 server before attempting an upgrade to MySQL 8.0.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
npgopala@siv20$ ./mysqlsh root:@localhost:3307 -e "util.checkForServerUpgrade();" mysqlsh: [Warning] Using a password on the command line interface can be insecure. The MySQL server at localhost:3307 will now be checked for compatibility issues for upgrade to MySQL 8.0... MySQL version: 5.7.24 - Source distribution 1) Usage of db objects with names conflicting with reserved keywords in 8.0 No issues found 2) Usage of utf8mb3 charset No issues found 3) Usage of use ZEROFILL/display length type attributes No issues found 4) Issues reported by 'check table x for upgrade' command No issues found 5) Table names in the mysql schema conflicting with new tables in 8.0 No issues found 6) Usage of old temporal type No issues found 7) Foreign key constraint names longer than 64 characters No issues found No known compatibility errors or issues for upgrading the target server to MySQL 8 were found. npgopala@siv20$ |
The utility did not report any errors to be fixed. So I can proceed with the upgrade of the server to MySQL 8.0 by replacing the old binaries.
- At this point, take a backup of the data directory using a backup or export utility such as mysqldump or mysqlpump. It is important to protect your data by creating a backup of your current databases which should include the mysql system database and log files.
- MySQL 8.0 binaries can be downloaded from here and the MySQL 8.0 server can be started on the old data directory. I have started with the default configuration here:
|
npgopala@siv20:~/workspace1/mysql-trunk/dbg-8.0$ ./runtime_output_directory/mysqld --basedir=/home/npgopala/workspace1/mysql-trunk/dbg-8.0 --datadir=/home/npgopala/data57 --log-error=/home/npgopala/workspace1/mysql-trunk/dbg-8.0/mysql1.log --socket=/home/npgopala/workspace1/mysql-trunk/dbg-8.0/mysql.sock --port=3307 --gdb --user=`whoami` --console --lc-messages-dir=./sql/share |
- The server is up and running, now I run the ‘mysql_upgrade’ to check and upgrade all system tables and also to check the user tables.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
|
npgopala@siv20$ ./runtime_output_directory/mysql_upgrade --socket=/home/npgopala/workspace1/mysql-trunk/dbg-8.0/mysql.sock --port=3307 --user=root Checking if update is needed. Checking server version. Running queries to upgrade MySQL server. Upgrading system table data. Checking system database. mysql.columns_priv OK mysql.component OK mysql.db OK mysql.default_roles OK mysql.engine_cost OK mysql.func OK mysql.general_log OK mysql.global_grants 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.password_history OK mysql.plugin OK mysql.procs_priv OK mysql.proxies_priv OK mysql.role_edges 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.0. Upgrading the sys schema. Checking databases. events.event_table OK events.event_table_2 OK foreign_keys.t1 OK foreign_keys.t2 OK foreign_keys.t3 OK foreign_keys.t4 OK foreign_keys.t5 OK foreign_keys.t6 OK foreign_keys.t7 OK foreign_keys.t8 OK partitions.p5_sub OK sp.t OK sys.sys_config OK tablespace.t1 OK tablespace.t2 OK tablespace.t3 OK tablespace.t4 OK test.55_temporal OK test.child OK test.geom OK test.jemp OK test.jemp_myisam OK test.opening_lines OK test.parent OK test.t_blackhole OK test.t_blob OK test.t_blob_myisam OK test.t_compressed OK test.t_compressed2 OK test.t_compressed3 OK test.t_dynamic OK test.t_gen_stored OK test.t_gen_stored_myisam OK test.t_gen_stored_myisam2 OK test.t_index OK test.t_json OK test.t_myisam_compressed OK test.t_sc~!@#$%^&*( OK test.vt2 OK triggers.t1 OK triggers.t2 OK view_with_column_names.t1 OK Upgrade process completed successfully. Checking if update is needed. npgopala@siv20$ |
The system tables have been upgrade and the user tables have been checked.
- Let me start a client connection and check if all my old databases are present.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
npgopala@siv20$ ./runtime_output_directory/mysql --socket=/home/npgopala/workspace1/mysql-trunk/dbg-8.0/mysql.sock --port=3307 --user=root Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 15 Server version: 8.0.12 Source distribution Copyright (c) 2000, 2018, 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. mysql> show databases; +------------------------+ | Database | +------------------------+ | events | | foreign_keys | | information_schema | | mysql | | partitions | | performance_schema | | sp | | sys | | tablespace | | test | | triggers | | view_with_column_names | +------------------------+ 12 rows in set (0.00 sec) mysql> |
- Shutdown the server and start the server. Check the log file to ensure there are no errors reported.
|
2018-06-06T09:11:28.167169Z 0 [System] [MY-010116] [Server] /home/npgopala/workspace1/mysql-trunk/dbg-8.0/runtime_output_directory/mysqld (mysqld 8.0.12) starting as process 27147 2018-06-06T09:11:30.261139Z 0 [System] [MY-010931] [Server] /home/npgopala/workspace1/mysql-trunk/dbg-8.0/runtime_output_directory/mysqld: ready for connections. Version: '8.0.12' socket: '/home/npgopala/workspace1/mysql-trunk/dbg-8.0/mysql.sock' port: 3307 Source distribution |
This marks the completion of the INPLACE upgrade process. If the upgrade fails due to some errors, the server reverts all changes to the data directory. An attempt to upgrade again to MySQL 8.0 involves:
- If any redo logs are present in the data directory, remove all of them.
- Start the MySQL 5.7 server on the same data directory.
- Fix all the errors that were reported during upgrade.
- Perform an INPLACE upgrade to MySQL 8.0 again.
In my next blog, I will discuss about the possible issues that maybe encountered while performing upgrade to MySQL 8.0. Meanwhile please review the upgrade prerequisites and the changes affecting upgrade to MySQL 8.0 prior to upgrade.
A detailed description about the upgrade process can be found in the MySQL documentation. As always, Thank You for using MySQL!