How to Upgrade MySQL 5.7 to 8.0.21 | MySQL Version Upgrade from 5.7 to 8.0.21

From this article you will know how to upgrade MySQL 5.7 to 8.0.21 in Linux. Please go through the recommendation once before starting the actual database upgrade.

  • If your MySQL installation contains a large amount of data that might take a long time to convert after an in-place upgrade, it may be useful to create a test instance for assessing the conversions that are required and the work involved to perform them. To create a test instance, make a copy of your MySQL instance that contains the MySQL database and other databases without the data. Run the upgrade procedure on the test instance to assess the work involved to perform the actual data conversion.
  • Rebuilding and reinstalling MySQL language interfaces is recommended when you install or upgrade to a new release of MySQL. This applies to MySQL interfaces such as PHP MySQL extensions and the Perl DBD::mysql module. 

MySQL Software Download and Installation

To read more about this section please read my detailed MySQL Installation Document. Here I am describing these steps in short.

cd /d02/mysql/product/
wget https://dev.mysql.com/get/Downloads/MySQL-8.0/mysql-8.0.21-linux-glibc2.12-x86_64.tar.xz
tar xvf mysql-8.0.21-linux-glibc2.12-x86_64.tar.xz
ln -s mysql-8.0.21-linux-glibc2.12-x86_64 8.0.21

Post-installation of MySQL 8.0.21 do the following –

  • Take a valid backup of your database before proceeding with the upgrade steps.
  • Change the base Directory in your .cnf file and make necessary changes in the file since some parameters of MySQL 5.7 aren’t supported in MySQL 8.0.21
# query_cache_size= 16M

[mysql]
port=3306
host=127.0.0.1
prompt="[\u@\h:\p]\_\d\_> "

[client]
port=3306
host=127.0.0.1

[mysqld]
port            = 3306
tmpdir          = /mysqldatabase/TEST/tmp
socket          = /mysqldatabase/TEST/admin/mysql.sock
default-authentication-plugin=mysql_native_password
collation-server = utf8mb4_general_ci
character-set-server = utf8mb4
tmpdir=/mysqldatabase/TEST/tmp/
log_error_verbosity = 3
pid-file=/mysqldatabase/TEST/data/mysql.pid

MySQL Version Upgradation Steps

Login to MySQL and check the innodb_fast_shutdown parameter. (It should be 1, else need to reset)[login without env file]

/d02/mysql/product/5.7.15/bin/mysql -h127.0.0.1 -P3306 -uroot -p

mysql> select @@innodb_fast_shutdown;
+------------------------+
| @@innodb_fast_shutdown |
+------------------------+
|                      1 |
+------------------------+
1 row in set (0.00 sec)

Shutdown the Database 

/d02/mysql/product/5.7.15/bin/mysqladmin -h127.0.0.1 -P3306 -uroot -p shutdown

Go to base directory to start the upgrade –

cd /d02/mysql/product/8.0.21/
$ bin/mysqld --defaults-file=/mysqldatabase/TEST/admin/my.cnf --upgrade=FORCE --daemonize --user=mysql
mysqld will log errors to /mysqldatabase/TEST/data/TEST.err
mysqld is running as pid 26074

Check the error log for more information, if nothing is found do the following –

$ . TEST.env
$ mysql
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 11
Server version: 8.0.21 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.

mysql> select @@version;
+-----------+
| @@version |
+-----------+
| 8.0.21    |
+-----------+
1 row in set (0.00 sec)

mysql> \s
--------------
/d02/mysql/product/8.0.21/bin/mysql  Ver 8.0.21 for Linux on x86_64 (MySQL Community Server - GPL)

Connection id:          11
Current database:
Current user:           root@localhost
SSL:                    Not in use
Current pager:          stdout
Using outfile:          ''
Using delimiter:        ;
Server version:         8.0.21 MySQL Community Server - GPL
Protocol version:       10
Connection:             Localhost via UNIX socket
Server characterset:    utf8mb4
Db     characterset:    utf8mb4
Client characterset:    utf8mb4
Conn.  characterset:    utf8mb4
UNIX socket:            /mysqldatabase/TEST/admin/mysql.sock
Binary data as:         Hexadecimal
Uptime:                 1 min 2 sec

Threads: 2  Questions: 12  Slow queries: 0  Opens: 2205  Flush tables: 4  Open tables: 26  Queries per second avg: 0.193
--------------

mysql> exit

Hope this document will help you for MySQL version upgrade on the Linux platform. Please let me know in case missing something. 

Leave a Comment

Your email address will not be published. Required fields are marked *