Firstly let’s make sure to update our system before starting in case of any out of date dependencies.
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:
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-server
Run the following command to check which files were actually installed:
[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 ~]# service mariadb status
You can now start the mariadb service with the service script as shown:
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:
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: