Install MySQL 5.7 on Fedora 23/22, CentOS/RHEL 7.2/6.7/5.11

MySQL Logo

Are you looking MariaDB 5.5/10.0/10.1 Install guide?

MySQL is a relational database management system (RDBMS) that runs as a server providing multi-user access to a number of databases. This is guide, howto install or upgrade MySQL Community Server latest version 5.7 (5.7.9) on Fedora 23/22/21, CentOS 7.2/6.7/5.11 and Red Hat (RHEL) 7.2/6.7/5.11. This guide works of course with Oracle Linux and Scientific Linux too and MySQL 5.6/5.5 installation is possible too.

Note: If you are upgrading MySQL (from earlier version), then make sure that you backup (dump and copy) your database and configs. And remember run mysql_upgrade command.

Install MySQL Database 5.7.9 on Fedora 23/22/21, CentOS 7.2/6.7/5.11, Red Hat (RHEL) 7.2/6.7/5.11

1. Change root user

2. Install MySQL YUM repository

Fedora

CentOS and Red Hat (RHEL)

3. Update or Install MySQL 5.7.9

Fedora 23/22

Fedora 21, CentOS 7.2/6.7/5.11 and Red Hat (RHEL) 7.2/6.7/5.11

4. Start MySQL server and autostart MySQL on boot

Fedora 23/22/21 and CentOS 7.2

CentOS 6.7/5.11 and Red Hat (RHEL) 6.7/5.11

5. Get Your Generated Random root Password

Example Output:

And password is: -et)QoL4MLid

6. MySQL Secure Installation

  • Change root password
  • Remove anonymous users
  • Disallow root login remotely
  • Remove test database and access to it
  • Reload privilege tables

Start MySQL Secure Installation with following command

Output:

Note: If you don’t want some reason, do a “MySQL Secure Installation” then at least it’s very important to change the root user’s password

7. Connect to MySQL database (localhost) with password

8. Create Database, Create MySQL User and Enable Remote Connections to MySQL Database

This example uses following parameters:

  • DB_NAME = webdb
  • USER_NAME = webdb_user
  • REMOTE_IP = 10.0.15.25
  • PASSWORD = password123
  • PERMISSIONS = ALL

Enable Remote Connection to MariaDB Server –> Open MySQL Port (3306) on Iptables Firewall (as root user again)

1. Fedora 23/22/21 and CentOS/Red Hat (RHEL) 7.2

1.1 Add New Rule to Firewalld

1.2 Restart firewalld.service

2. CentOS/Red Hat (RHEL) 6.7/5.11

2.1 Edit /etc/sysconfig/iptables file:

2.2 Add following INPUT rule:

2.3 Restart Iptables Firewall:

3. Test remote connection

Share this post

258 Comments

  1. Hi,

    I’ve followed the procedure above an at point 6 I run into problems. How can I change the root password to something that MySQL accept? ( I give a 10 letter password below with Capitals and numbers in it)

    # /usr/bin/mysql_secure_installation

    Securing the MySQL server deployment.

    Connecting to MySQL server using password in ‘/root/.mysql_secret’
    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) : y

    New password:

    Re-enter new password:

    Estimated strength of the password: 50
    Do you wish to continue with the password provided?(Press y|Y for Yes, any other key for No) : Y
    … Failed! Error: Your password does not satisfy the current policy requirements

    Reply
    • Hi Thommy,

      Following is from MySQL docs:


      The three levels of password checking are LOW, MEDIUM, and STRONG. The default is MEDIUM; to change this, modify the value of validate_password_policy. The policies implement increasingly strict password tests. The following descriptions refer to default parameter values; these can be modified by changing the appropriate system variables.

      LOW policy tests password length only. Passwords must be at least 8 characters long.

      MEDIUM policy adds the conditions that passwords must contain at least 1 numeric character, 1 lowercase and uppercase character, and 1 special (nonalphanumeric) character.

      STRONG policy adds the condition that password substrings of length 4 or longer must not match words in the dictionary file, if one has been specified.

      Default level is MEDIUM, so you need at least 1 numeric character, 1 lowercase and uppercase character, and 1 special (nonalphanumeric) character. Alternatively you can change it to LOW, then at least 8 characters long password should be okay.

      Or you can disable it using:

      Reply
      • Thanks JR, that did the trick. Can’t see how I missed the special character. Got to get some sleep maybe …

        Reply

Submit a Comment

Your email address will not be published. Required fields are marked *