Installing MySQL (MariaDB) on CentOS 7

On CentOS 7 the MySQL packages have been replaced with the community developed MariaDB packages which are drop in replacements to the MySQL counterparts.

So first thing’s first, install MariaDB:

[root@mail ~]# yum -y install mariadb-server mariadb

The -y means yum will automatically answer yes to any questions,
mariadb-server the server package and mariadb is the client package.

Next enable the MariaDB service and start it up using systemctl:

[root@mail ~]# systemctl enable mariadb
[root@mail ~]# systemctl start mariadb

The next step is optional but recommended, run the mysql_secure_installation command to improve the security of the installation:

[root@mail ~]# mysql_secure_installation

I won’t run through each of the steps in there but it will ask you if you want to set a root password, remove anonymous users, disallow root login remotely and then remove the test database. This should close down some of the more open aspects of a MariaDB installation.

You can that test that you’ve got access by logging into MariaDB using the root password you set in the mysql_secure_installation (or blank if you haven’t set one):

[root@mail ~]# mysql -u root -p
Enter password: 
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 11
Server version: 5.5.37-MariaDB MariaDB Server

Copyright (c) 2000, 2014, Oracle, Monty Program Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [(none)]>

Note that the mysql commands are still used and that MariaDB works like MySQL despite it providing a MariaDB prompt.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s