• Arun Kumar

Install MySQL 8 on Oracle Linux

Installing MySQL on Oracle Linux is simple and straightforward. Download the latest version of MySQL based on your OS version.


Server Configuration


Disable SE Linux on the server as root user

setenforce Permissive

vi /etc/selinux/config    --> change SELINUX to permissive

Install wget utility (if not installed) to download MySQL RPM directly inside Linux server

yum -y install wget

Install MySQL 8


At the time of writing this article, below was the latest MySQL rpm. You must download the latest rpm for RedHat, copy download link and use wget to download MySQL directly on your Linux server

wget https://repo.mysql.com//mysql80-community-release-el7-6.noarch.rpm

Install the downloaded RPM

yum -y install mysql80-community-release-el7-6.noarch.rpm

Check if repo is enabled to download MySQL

yum repolist enabled | grep mysql

Run below to install MySQL 8. The first command is required for updated GPG key

rpm --import https://repo.mysql.com/RPM-GPG-KEY-mysql-2022
yum -y install mysql-community-server

Create directories to hold database files

mkdir -p /u01/data
mkdir -p /u01/log_bin
mkdir -p /u01/tmpdir
chown -R mysql:mysql /u01
chmod -R 755 /u01

Edit /etc/my.cnf file and add below parameters

user=mysql
log_bin=/u01/log_bin/myDB
datadir=/u01/data
tmpdir=/u01/tmpdir

Enable MySQL services to autostart on reboot

systemctl enable mysqld
systemctl start mysqld
systemctl status mysqld

Secure MySQL 8 Installation


Check the temporary password for MySQL

grep 'temporary password' /var/log/mysqld.log

Secure MySQL

/usr/bin/mysql_secure_installation

Securing the MySQL server deployment.

Enter password for user root: <enter temp password>

The existing password for the user account root has expired. Please set a new password.

New password: <give new password>

Re-enter new password: <re-enter new password>
The 'validate_password' component is installed on the server.
The subsequent steps will run with the existing configuration
of the component.
Using existing password for root.

Estimated strength of the password: 100 
Change the password for root ? ((Press y|Y for Yes, any other key for No) : <just hit enter>

 ... skipping.
By default, a MySQL installation has an anonymous user,
allowing anyone to log into MySQL without having to have
a user account created for them. This is intended only for
testing, and to make the installation go a bit smoother.
You should remove them before moving into a production
environment.

Remove anonymous users? (Press y|Y for Yes, any other key for No) : <just hit enter>

 ... skipping.

Normally, root should only be allowed to connect from
'localhost'. This ensures that someone cannot guess at
the root password from the network.

Disallow root login remotely? (Press y|Y for Yes, any other key for No) : <just hit enter>

 ... skipping.
By default, MySQL comes with a database named 'test' that
anyone can access. This is also intended only for testing,
and should be removed before moving into a production
environment.

Remove test database and access to it? (Press y|Y for Yes, any other key for No) : <just hit enter>

 ... skipping.
Reloading the privilege tables will ensure that all changes
made so far will take effect immediately.

Reload privilege tables now? (Press y|Y for Yes, any other key for No) : <just hit enter>

 ... skipping.
All done! 

Connect to MySQL and check the databases

mysql --user=root --password

mysql> show databases;

Enjoy!

41 views

Recent Posts

See All