How to Install MySQL on CentOS 7

MySQL is a popular database management system used for web and server applications. However, MySQL is no longer in CentOS’s repositories and MariaDB has become the default database system offered. MariaDB is considered a drop-in replacement for MySQL and would be sufficient if you just need a database system in general.

Before You Begin

  1. Ensure that you have followed the Getting Started and Securing Your Server guides, and the Linode’s hostname is set.

    To check your hostname run:

    hostname
    hostname -f
    

    The first command should show your short hostname, and the second should show your fully qualified domain name (FQDN).

  2. Update your system:

    sudo yum update
    
  3. You will need wget to complete this guide. It can be installed as follows:

    yum install wget

Install MySQL

MySQL must be installed from the community repository.

  1. Download and add the repository, then update.

    wget http://repo.mysql.com/mysql-community-release-el7-5.noarch.rpm
    sudo rpm -ivh mysql-community-release-el7-5.noarch.rpm
    yum update
    
  2. Install MySQL as usual and start the service. During installation, you will be asked if you want to accept the results from the .rpm file’s GPG verification. If no error or mismatch occurs, enter y.

    sudo yum install mysql-server
    sudo systemctl start mysqld
    

MySQL will bind to localhost (127.0.0.1) by default. 

Harden MySQL Server

  1. Run the mysql_secure_installation script to address several security concerns in a default MySQL installation.

    sudo mysql_secure_installation
    

You will be given the choice to change the MySQL root password, remove anonymous user accounts, disable root logins outside of localhost, and remove test databases. It is recommended that you answer yes to these options. You can read more about the script in the MySQL Reference Manual.




  • mysql
  • 0 Users Found This Useful
Was this answer helpful?

Related Articles

Windows: Accessing Your Server with Remote Desktop

This article explains how to use Remote Desktop to access your Windows server’s desktop from...

What is Reverse DNS?

Reverse DNS (rDNS) is name resolution that looks up an IP addresses to obtain a domain name,...

Setting up Nameserver DNS Using cPanel/WebHost Manager

cPanel's WebHost Manager® (WHM) lets you use your own domain name as a nameserver for websites...

How to install the php-mcrypt module on a Plesk server

Question How to install the php-mcrypt module on a Plesk server? Answer Notes: The solution in...

How to change virtual hosts location in Plesk for Linux?

  In Plesk for Linux, transvhosts.pl utility can be used to change the location for all virtual...