Saturday, June 15, 2024

MySQL 8 - Part I: Installation

1. Download MySQL packages from Oracle eDelivery (Server, Shell, ...)

[root@mysql-saigon mysql8]# ls -l
total 961092
-rw-r--r--. 1 root root   4010566 Mar 31 16:46 mysql-commercial-backup-8.0.37-1.1.el9.x86_64.rpm
-rw-r--r--. 1 root root  20388471 Mar 31 16:46 mysql-commercial-backup-debuginfo-8.0.37-1.1.el9.x86_64.rpm
-rw-r--r--. 1 root root   4105053 Mar 31 16:46 mysql-commercial-client-8.0.37-1.1.el9.x86_64.rpm
-rw-r--r--. 1 root root  27305094 Mar 31 16:46 mysql-commercial-client-debuginfo-8.0.37-1.1.el9.x86_64.rpm
-rw-r--r--. 1 root root   1457867 Mar 31 16:46 mysql-commercial-client-plugins-8.0.37-1.1.el9.x86_64.rpm
-rw-r--r--. 1 root root   2052547 Mar 31 16:46 mysql-commercial-client-plugins-debuginfo-8.0.37-1.1.el9.x86_64.rpm
-rw-r--r--. 1 root root    570629 Mar 31 16:46 mysql-commercial-common-8.0.37-1.1.el9.x86_64.rpm
-rw-r--r--. 1 root root   7680309 Mar 31 16:46 mysql-commercial-debuginfo-8.0.37-1.1.el9.x86_64.rpm
-rw-r--r--. 1 root root   7311390 Mar 31 16:46 mysql-commercial-devel-8.0.37-1.1.el9.x86_64.rpm
-rw-r--r--. 1 root root   2383993 Mar 31 16:46 mysql-commercial-icu-data-files-8.0.37-1.1.el9.x86_64.rpm
-rw-r--r--. 1 root root   1588746 Mar 31 16:46 mysql-commercial-libs-8.0.37-1.1.el9.x86_64.rpm
-rw-r--r--. 1 root root   2412596 Mar 31 16:47 mysql-commercial-libs-debuginfo-8.0.37-1.1.el9.x86_64.rpm
-rw-r--r--. 1 root root  57277741 Mar 31 16:48 mysql-commercial-server-8.0.37-1.1.el9.x86_64.rpm
-rw-r--r--. 1 root root  27151180 Mar 31 16:48 mysql-commercial-server-debug-8.0.37-1.1.el9.x86_64.rpm
-rw-r--r--. 1 root root 170157585 Mar 31 16:48 mysql-commercial-server-debug-debuginfo-8.0.37-1.1.el9.x86_64.rpm
-rw-r--r--. 1 root root 220976584 Mar 31 16:48 mysql-commercial-server-debuginfo-8.0.37-1.1.el9.x86_64.rpm
-rw-r--r--. 1 root root 366474178 Mar 31 16:50 mysql-commercial-test-8.0.37-1.1.el9.x86_64.rpm
-rw-r--r--. 1 root root  20801351 Mar 31 16:50 mysql-commercial-test-debuginfo-8.0.37-1.1.el9.x86_64.rpm
-rw-r--r--. 1 root root   4425344 Mar 31 16:57 mysql-router-commercial-8.0.37-1.1.el9.x86_64.rpm
-rw-r--r--. 1 root root  35571693 Mar 31 16:57 mysql-router-commercial-debuginfo-8.0.37-1.1.el9.x86_64.rpm
-rw-r--r--. 1 root root      1472 Apr 27 20:53 README.txt

2. Install MySQL packages

[root@mysql-saigon mysql8]# rpm -ivh mysql-commercial-debuginfo-8.0.37-1.1.el8.x86_64.rpm
[root@mysql-saigon mysql8]# yum install mysql-commercial-{server,client,client-plugins,icu-data-files,common,libs}-*

Patching to version Mysql 8.4
  • Download newest MySQL 8.4 packages from MOS
  • To apply the latest patches to an existing installation, all that is required is to download and install the latest patch release.
[root@mysql-saigon patch]# ls -l
total 1456528
-rw-r--r-- 1 mysql mysql   4098340 Jun 22 20:18 mysql-commercial-backup-8.4.0-1.1.el8.x86_64.rpm
-rw-r--r-- 1 mysql mysql  19090324 Jun 22 20:18 mysql-commercial-backup-debuginfo-8.4.0-1.1.el8.x86_64.rpm
-rw-r--r-- 1 mysql mysql  13434336 Jun 22 20:18 mysql-commercial-client-8.4.0-1.1.el8.x86_64.rpm
-rw-r--r-- 1 mysql mysql  22673600 Jun 22 20:18 mysql-commercial-client-debuginfo-8.4.0-1.1.el8.x86_64.rpm
-rw-r--r-- 1 mysql mysql   3991796 Jun 22 20:18 mysql-commercial-client-plugins-8.4.0-1.1.el8.x86_64.rpm
-rw-r--r-- 1 mysql mysql   5690492 Jun 22 20:18 mysql-commercial-client-plugins-debuginfo-8.4.0-1.1.el8.x86_64.rpm
-rw-r--r-- 1 mysql mysql    709260 Jun 22 20:18 mysql-commercial-common-8.4.0-1.1.el8.x86_64.rpm
-rw-r--r-- 1 mysql mysql  10046508 Jun 22 20:18 mysql-commercial-debuginfo-8.4.0-1.1.el8.x86_64.rpm
-rw-r--r-- 1 mysql mysql  23103448 Jun 22 20:18 mysql-commercial-devel-8.4.0-1.1.el8.x86_64.rpm
-rw-r--r-- 1 mysql mysql   2350976 Jun 22 20:18 mysql-commercial-icu-data-files-8.4.0-1.1.el8.x86_64.rpm
-rw-r--r-- 1 mysql mysql   1542176 Jun 22 20:18 mysql-commercial-libs-8.4.0-1.1.el8.x86_64.rpm
-rw-r--r-- 1 mysql mysql   2337624 Jun 22 20:18 mysql-commercial-libs-debuginfo-8.4.0-1.1.el8.x86_64.rpm
-rw-r--r-- 1 mysql mysql  62328968 Jun 22 20:18 mysql-commercial-server-8.4.0-1.1.el8.x86_64.rpm
-rw-r--r-- 1 mysql mysql  31401620 Jun 22 20:18 mysql-commercial-server-debug-8.4.0-1.1.el8.x86_64.rpm
-rw-r--r-- 1 mysql mysql 185530892 Jun 22 20:18 mysql-commercial-server-debug-debuginfo-8.4.0-1.1.el8.x86_64.rpm
-rw-r--r-- 1 mysql mysql 223241844 Jun 22 20:18 mysql-commercial-server-debuginfo-8.4.0-1.1.el8.x86_64.rpm
-rw-r--r-- 1 mysql mysql 350709268 Jun 22 20:19 mysql-commercial-test-8.4.0-1.1.el8.x86_64.rpm
-rw-r--r-- 1 mysql mysql  27879616 Jun 22 20:19 mysql-commercial-test-debuginfo-8.4.0-1.1.el8.x86_64.rpm
-rw-r--r-- 1 mysql mysql   5272884 Jun 22 20:19 mysql-router-commercial-8.4.0-1.1.el8.x86_64.rpm
-rw-r--r-- 1 mysql mysql  38087640 Jun 22 20:19 mysql-router-commercial-debuginfo-8.4.0-1.1.el8.x86_64.rpm
-rw-r--r-- 1 mysql mysql  35218892 Jun 22 20:19 mysql-shell-commercial-8.4.0-1.1.el8.x86_64.rpm
-rw-r--r-- 1 mysql mysql 422700972 Jun 22 20:19 mysql-shell-commercial-debuginfo-8.4.0-1.1.el8.x86_64.rpm

[root@mysql-saigon patch]# rpm -ivh mysql-commercial-debuginfo-8.4.0-1.1.el8.x86_64.rpm
[root@mysql-saigon patch]# yum upgrade mysql-commercial-{server,client,client-plugins,icu-data-files,common,libs}-*

[mysql@mysql-saigon ~]$ mysql -V
mysql  Ver 8.4.0-commercial for Linux on x86_64 (MySQL Enterprise Server - Commercial)

Note: If installing fresh server, we can install packages version 8.4 directly

3. Edit in /etc/passwd for mysql /bin/bash

4. Start mysqld.service
[root@mysql-saigon ~]# systemctl start mysqld.service 
[root@mysql-saigon ~]# systemctl status mysqld.service 
[root@mysql-saigon ~]# systemctl enable mysqld.service 

[root@mysql-saigon ~]# mysql_secure_installation

5. Import sample database
  • Download sample mysqlsampledatabase.sql 
  • Import sample database
[mysql@mysql-saigon ~]$ mysql -u root -p
mysql> source /source/mysqlsampledatabase.sql
mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| classicmodels      |
| information_schema |
| mysql              |
| performance_schema |
| sys                |
+--------------------+
5 rows in set (0.00 sec)

Note: Should change root password after importing full database.

6. Install MySQL shell packages

[root@mysql-saigon shell]# ls -l
total 664960
-rw-r--r--. 1 root root  27161664 Apr 10 14:42 mysql-shell-commercial-8.0.37-1.1.el9.x86_64.rpm
-rw-r--r--. 1 root root 653742527 Apr 10 14:43 mysql-shell-commercial-debuginfo-8.0.37-1.1.el9.x86_64.rpm

[root@mysql-saigon shell]# rpm -ivh *
warning: mysql-shell-commercial-8.0.37-1.1.el9.x86_64.rpm: Header V4 RSA/SHA256 Signature, key ID a8d3785c: NOKEY
Verifying...                          ################################# [100%]
Preparing...                          ################################# [100%]
Updating / installing...
   1:mysql-shell-commercial-debuginfo-################################# [ 50%]
   2:mysql-shell-commercial-8.0.37-1.1################################# [100%]

[mysql@mysql-saigon ~]$ mysqlsh
MySQL  JS > \sql
MySQL  SQL > \connect root@localhost:3306
...
 MySQL  localhost:3306 ssl  SQL > 
 MySQL  localhost:3306 ssl  SQL > SHOW DATABASES;
+--------------------+
| Database           |
+--------------------+
| classicmodels      |
| information_schema |
| mysql              |
| performance_schema |
| sys                |
+--------------------+
5 rows in set (0.0029 sec)

7. Change default data directory
  • Identify Current MySQL Data Directory
  • Create NEW Data Directory
  • Stop Database service
  • Copy MySQL Data Directory to a New Location
  • Edit datadir, socket in /etc/my.cnf to NEW Data Directory
  • Start Database service
  • Verify the Changes
  • Cleanup
Note: We can use this command to initialize database
[root@mysql-saigon ~]$ mysqld --initialize --user=mysql
[root@mysql-saigon ~]$ systemctl start mysqld.service
[root@mysql-saigon ~]# mysql_secure_installation

Ref: