Database

How to Install MySQL 8.0 on CentOS, RHEL and Fedora Systems

install-mysql-8.0
mm
Written by Santosh Prasad

MySQL server is the most popular open source relational database management system (RDBMS). MySQL has become the leading database choice web-based applications, Used by high profile web properties including Facebook, Youtube, Twitter, Yahoo! and many more.

In this article I will show how you can install MySQL 8.0 on CentOS, RHEL and Fedora systems.

Install MySQL 8.0

Follow the below steps to install MySQL 8.0 on CentOS, RHEL and Fedora systems.

Step #1 : Install and Enable MySQL Community Repository

First of all you have to install MySQL community repository on your system. Follow the below command to install required repository.

### On CentOS/RHEL 7 system ###
# rpm -Uvh https://repo.mysql.com/mysql57-community-release-el7-11.noarch.rpm

### On CentOS/RHEL 6 system ###
# rpm -Uvh https://repo.mysql.com/mysql57-community-release-el6-11.noarch.rpm

### On Fedora 26 system ###
# rpm -Uvh https://repo.mysql.com/mysql57-community-release-fc26-10.noarch.rpm

### On Fedora 25 system ###
# rpm -Uvh https://repo.mysql.com/mysql57-community-release-fc25-10.noarch.rpm

### On Fedora 24 system ###
# rpm -Uvh https://repo.mysql.com/mysql57-community-release-fc24-10.noarch.rpm

Step #2 : Install MySQL 8.0 Community Server

After enabling and installing MySQL community repository now install MySQL server. Follow the below command to install MySQL 8.0 community server on your system.

On CentOS/RHEL 7

# yum --enablerepo=mysql80-community install mysql-community-server    

On Fedora 26/25/24

# dnf --enablerepo=mysql80-community install mysql-community-server  

Step #3 : Find MySQL Root Password

If you install MySQL 8.0 it will create a temporary password for MySQL root user. You can find this password using its log file as shown below.

# grep "A temporary password" /var/log/mysqld.log

[Note] A temporary password is generated for [email protected]: hosygMikj1+t636

Step #4 : Start MySQL Service

After installing MySQL server now lets start MySQL service using below command.

Using SysVinit

# service mysqld start

Using Systemd

# systemctl start mysqld.service

Step #5 : MySQL Secure Installation

If you are installing MySQL first time run mysql_secure_installation to secure your MySQL server as shown below.

# mysql_secure_installation

You will get some output like below:

New password:

Re-enter new password:
The 'validate_password' plugin is installed on the server.
The subsequent steps will run with the existing configuration
of the plugin.
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) : No

 ... 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) : y
Success.


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) : y
Success.

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) : y
 - Dropping test database...
Success.

 - Removing privileges on test database...
Success.

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) : y
Success.

All done!

Step #6 : Restart and Eanble MySQL Service at Boot Time

After following all MySQL installation now restart MySQL service using below command.

### Using SysVinit
# service mysqld restart

### Using Systemd
# systemctl restart mysqld.service

Now enable service to auto start at system boot time using below command.

### Using SysVinit
# chkconfig mysqld on

### Using Systemd
# systemctl enable mysqld.service

Step #7 : Connect to MySQL server

Now connect to your MySQL database server using below command. It will prompt for password for authentication.

# mysql -h localhost -u root -p

Once successfully login you will get MySQL command prompt.

Thank you! for visiting Look Linux.

If you find this tutorial helpful please share with your friends to keep it alive. For more helpful topic browse my website www.looklinux.com. To become an author at Look Linux Submit Article. Stay connected to Facebook.

About the author

mm

Santosh Prasad

Hi! I'm Santosh and I'm here to post some cool article for you. If you have any query and suggestion please comment in comment section.

Leave a Comment