Step by Step Database MySql 8 Installation using Binaries
Step by Step Database MySql 8 Installation using Binaries
In the previous blog, we have performed MySql 8 installation using YUM Repository click here to read more. In this blog, we are going to perform step by step MySql 8 installation using binaries in OEL 7.9 (Oracle Linux Enterprise).
Download MySql 8 tar binary using wget command inside Server. Please note wget command require internet access in your server.
[root@test-machine02 tmp]# wget https://cdn.mysql.com//Downloads/MySQL-8.0/mysql-8.0.22-el7-x86_64.tar.gz --2021-01-06 13:49:10-- https://cdn.mysql.com//Downloads/MySQL-8.0/mysql-8.0.22-el7-x86_64.tar.gz Resolving cdn.mysql.com (cdn.mysql.com)... 92.122.248.30 Connecting to cdn.mysql.com (cdn.mysql.com)|92.122.248.30|:443... connected. HTTP request sent, awaiting response... 200 OK Length: 931826505 (889M) [application/x-tar-gz] Saving to: âmysql-8.0.22-el7-x86_64.tar.gzâ 100%[====================================================================================================================================================>] 931,826,505 3.13MB/s in 4m 48s 2021-01-06 13:53:59 (3.09 MB/s) - âmysql-8.0.22-el7-x86_64.tar.gzâ saved [931826505/931826505] [root@test-machine02 tmp]# [root@test-machine02 tmp]# ls -ltr mysql* -rw-r--r--. 1 root root 931826505 Sep 23 20:56 mysql-8.0.22-el7-x86_64.tar.gz
We will use /u01/mysql-8 as our base directory. So we will untar mysql setup files in /u01 mount point and move created folder to name as mysql-8
[root@test-machine02 tmp]# tar -xvf mysql-8.0.22-el7-x86_64.tar.gz --directory /u01/ mysql-8.0.22-el7-x86_64/bin/ mysql-8.0.22-el7-x86_64/bin/myisam_ftdump mysql-8.0.22-el7-x86_64/bin/myisamchk mysql-8.0.22-el7-x86_64/bin/myisamlog [root@test-machine02 tmp]# cd /u01 [root@test-machine02 u01]# ls -ltr total 4 drwxr-xr-x. 9 root root 4096 Jan 6 14:09 mysql-8.0.22-el7-x86_64 [root@test-machine02 u01]# mv mysql-8.0.22-el7-x86_64 mysql-8 [root@test-machine02 u01]# ls -ltr total 4 drwxr-xr-x. 9 root root 4096 Jan 6 14:09 mysql-8
Create mysql group and mysql userid. You need to run your MySQL database using the “mysql” user. Make sure your SELinux setting is in Permissive mode. Use command getenforce to check SELinux setting if it is showing enforcing you can go ahead and edit file /etc/selinux/config and change parameter for SELINUX to permissive and reboot your Server.
[root@test-machine02 log]# groupadd mysql [root@test-machine02 log]# useradd -r -g mysql -s /bin/false mysql [root@test-machine02 log]# getenforce Permissive [root@test-machine02 selinux]# cat /etc/selinux/config # This file controls the state of SELinux on the system. # SELINUX= can take one of these three values: # enforcing - SELinux security policy is enforced. # permissive - SELinux prints warnings instead of enforcing. # disabled - No SELinux policy is loaded. SELINUX=permissive
Create directory data and log inside /u01/mysql-8 and change permission of group and owner to mysql using the command chown.
[root@test-machine02 mysql-8]# mkdir data [root@test-machine02 mysql-8]# mkdir log [root@test-machine02 u01]# chown -R mysql:mysql /u01/mysql-8 [root@test-machine02 u01]# [root@test-machine02 u01]# ls -ld /u01/mysql-8 drwxr-xr-x. 11 mysql mysql 4096 Jan 6 14:13 /u01/mysql-8
Create config file with below parameters in default location /etc/my.cnf
[root@test-machine02 etc]# cat /etc/my.cnf [mysqld] user=mysql basedir=/u01/mysql-8 datadir=/u01/mysql-8/data socket=/u01/mysql-8/mysql.sock log_error=/u01/mysql-8/log/mysqld.log pid_file=/u01/mysql-8/mysqld.pid innodb_directories="/u01/mysql-8" [client] port=3306 socket=/u01/mysql-8/mysql.sock
Initialize the data directory, This is the important step that will help to initialize your data directory and will create a Root user temporary password. Please note root password is mention in the last line.
[root@test-machine02 log]# /u01/mysql-8/bin/mysqld --defaults-file=/etc/my.cnf --initialize --user=mysql 2021-01-06T11:41:11.723928Z 0 [System] [MY-013169] [Server] /u01/mysql-8/bin/mysqld (mysqld 8.0.22) initializing of server in progress as process 1784 2021-01-06T11:41:11.730102Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started. 2021-01-06T11:41:12.141063Z 1 [System] [MY-013577] [InnoDB] InnoDB initialization has ended. 2021-01-06T11:41:12.945182Z 6 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: lrgq(tT#s5T; [root@test-machine02 log]# [root@test-machine02 mysql-8]# cd data [root@test-machine02 data]# ls -ltr total 164284 -rw-r-----. 1 mysql mysql 50331648 Jan 6 14:41 ib_logfile1 -rw-r-----. 1 mysql mysql 8585216 Jan 6 14:41 #ib_16384_1.dblwr drwxr-x---. 2 mysql mysql 8192 Jan 6 14:41 performance_schema -rw-r-----. 1 mysql mysql 56 Jan 6 14:41 auto.cnf -rw-------. 1 mysql mysql 1680 Jan 6 14:41 ca-key.pem -rw-r--r--. 1 mysql mysql 1112 Jan 6 14:41 ca.pem -rw-------. 1 mysql mysql 1676 Jan 6 14:41 server-key.pem -rw-r--r--. 1 mysql mysql 1112 Jan 6 14:41 server-cert.pem -rw-------. 1 mysql mysql 1676 Jan 6 14:41 client-key.pem -rw-r--r--. 1 mysql mysql 1112 Jan 6 14:41 client-cert.pem -rw-r--r--. 1 mysql mysql 452 Jan 6 14:41 public_key.pem -rw-------. 1 mysql mysql 1676 Jan 6 14:41 private_key.pem
Once you have done the initialization, you are good to start the MySQL services.
Set mysqld bin path in your environment variable so you don’t need to mention the full path for mysqld. Here we have started the MySQL services in the background.
[root@test-machine02 data]# export PATH=$PATH:/u01/mysql-8/bin [root@test-machine02 data]# mysqld --defaults-file=/etc/my.cnf --user=mysql & [1] 1851 /u01/mysql-8/bin/mysqld (mysqld 8.0.22) starting as process 1851 2021-01-06T12:00:42.948232Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started. 2021-01-06T12:00:46.940272Z 1 [System] [MY-013577] [InnoDB] InnoDB initialization has ended. 2021-01-06T12:00:47.597031Z 0 [System] [MY-011323] [Server] X Plugin ready for connections. Bind-address: '::' port: 33060, socket: /tmp/mysqlx.sock 2021-01-06T12:00:49.367619Z 0 [Warning] [MY-010068] [Server] CA certificate ca.pem is self signed. 2021-01-06T12:00:49.367934Z 0 [System] [MY-013602] [Server] Channel mysql_main configured to support TLS. Encrypted connections are now supported for this channel. 2021-01-06T12:00:49.393075Z 0 [System] [MY-010931] [Server] /u01/mysql-8/bin/mysqld: ready for connections. Version: '8.0.22' socket: '/u01/mysql-8/mysql.sock' port: 3306 MySQL Community Server - GPL.
Login MYSQL using the temporary password mention above. You need to change your root password before running any commands.
[root@test-machine02 data]# mysql -hlocalhost -uroot -p Enter password: Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 8 Server version: 8.0.22 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> status ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement. mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'Root@1234'; Query OK, 0 rows affected (0.00 sec) mysql> status -------------- /u01/mysql-8/bin/mysql Ver 8.0.22 for Linux on x86_64 (MySQL Community Server - GPL) Connection id: 8 Current database: Current user: root@localhost SSL: Not in use Current pager: stdout Using outfile: '' Using delimiter: ; Server version: 8.0.22 Protocol version: 10 Connection: Localhost via UNIX socket Server characterset: utf8mb4 Db characterset: utf8mb4 Client characterset: utf8mb4 Conn. characterset: utf8mb4 UNIX socket: /u01/mysql-8/mysql.sock Binary data as: Hexadecimal Uptime: 2 min 24 sec Threads: 2 Questions: 7 Slow queries: 0 Opens: 128 Flush tables: 3 Open tables: 46 Queries per second avg: 0.048 --------------
Click here for Database MySql 8 Installation using Yum Repository Method
This document is only for learning purpose and always validate in the LAB environment first before applying in the LIVE environment.
Hope so you like this article!
Please share your valuable feedback/comments/subscribe and follow us below and don’t forget to click on the bell icon to get the latest update:
Registration Link
Telegram Technical Group
Facebook
Facebook Page
Linkedin Group
Linkedin Page
83 total views, 5 views today
Hello and welcome to DBsGuru,
I’m Jamsher Khan working as Senior Oracle DBA based in KSA-Jeddah, I have working experience in Oracle DBA, SQL Server, MySql, Linux, Golden Gate, ODA.
Thanks for the visits!
Share Learn Grow!