Skip to main content

Install MySQL

Installing MySQL on Centos

Uninstall MariaDB

  1. Uninstall MariaDB from the server
yum remove MariaDB-server MariaDB-client

Add the MySQL repository

  1. Download and add the following MySQL Yum repository
Downloading respository data
============================

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

Installing the repository data
==============================

yum localinstall mysql80-community-release-el7-1.noarch.rpm

Verify if the MySQL Yum repository has been added successfully

  1. with the command below very that the MySQL Yum repository has been added successfully
yum repolist enabled | grep "mysql.*-community.*"

The result should be similar to

012.PNG

Installing MySQL Release Series

If a specific release series is required follow the following steps

  1. If not already installed, install yum-config-manager

    yum update && yum install yum-utils

  2. Disable the current active sub-repository, where [xx] replaces the version number

    yum-config-manager --disable mysql[xx]-community
  3. Enable the appropriate sub-repository, where [xx] replaces the version number

    yum-config-manager --enable mysql[xx]-community

Install MySQL

  1. Install MySQL with the command below

    yum install mysql-community-server

Start and enable MySQL

  1. Start and enable MySQL with the commands below
Start mySQL
===========

systemctl start mysqld

Enable Mysql
============

systemctl enable mysqld

Secure MySQL installation

  1. Lastly, secure the installation of MySQL by running the command below and following the prompts
mysql_secure_installation