CentOS MySQL MariaDB

Install MySQL on CentOS 7.5

In this tutorial I will show you how to install MySQL Database on CentOS 7.5 operating system using the yum commands and the built in utilities of CentOS. It can be installed from source, or additional ways, but we will do it using CentOS native commands.

Firstly let’s make sure to update our system before starting in case of any out of date dependencies.

[root@centos7-linuxhint ~]# yum update

There are numerous packages available on CentOS related to MySQL without having to add the EPEL extra package repository. To see a list of them all try this command for yum search:

[root@centos7-linuxhint ~]# yum search mysql

Looking down the list, you can see there is no option for mysql, itself, just various related packages. The reason is that Oracle purchased MySQL when they bought Sun Microsystems, and the founders of MySQL restarted the pure open source initiative with a new name called mariadb, but its still basically MySQL but fully open source.

So lets install mariadb package.

Installing Mariadb Server

Run the yum install command for mariadb as such:

[root@centos7-linuxhint ~]# yum install mariadb
[root@centos7-linuxhint ~]# yum install mariadb-server

Run the following command to check which files were actually installed:

[root@centos7-linuxhint ~]# rpm -ql mariadb
[root@centos7-linuxhint ~]# rpm -ql mariadb-server

Using the MariaDB Service Controller

MySQL and MariaDB come with native utilities to initialize a database as well as starting and stopping a database. mysql_install_db and mysqladmin are two primary utilities. However given we are focused on the CentOS linux distribution lets look at the service file that comes with the RPM files and can be used for a native CentOS experience.

The service comes in a script file and also can be run with typical commands such as the following:

[root@centos7-linuxhint ~]# ls -lart /usr/lib/systemd/system/mariadb.service
[root@centos7-linuxhint ~]# service mariadb status

You can now start the mariadb service with the service script as shown:

[root@centos7-linuxhint ~]# service mariadb start

To verify the service is running lets connect to the DB with the mysql command line utility and run some basic commands once we are connected:

[root@centos7-linuxhint ~]# mysql


That’s all it takes to get started installing MySQL and using it on CentOS, but of course to be an advanced user you will want to learn a lot more. For more info check the links below:

About the author

Linux Wolfman

Linux Wolfman

Linux Wolfman is interested in Operating Systems, File Systems, Databases and Analytics and always watching for new technologies and trends. Reach me by tweeting to @linuxhint and ask for the Wolfman.