Install LAMP Stack (Linux, Apache, MariaDB, php, phpMyAdmin) on CentOS/RHEL 6 & CentOS/RHEL 7

3) MariaDB/MySQL installation

MariaDB is a drop in replacement for MySQL. MariaDB is open-source relational database management system (RDBMS) which is supporting database access. It’s robust, scalable, and reliable SQL server for high availability databases as free of cost.

[Install MariaDB on RHEL/CentOS 7]
# yum -y install mariadb-server mariadb

By default MariaDB does’t available for CentOS/RHEL 6 systems. So, we need to Add MariaDB repo. Create file /etc/yum.repos.d/MariaDB.repo then Copy and paste it.

[Install MariaDB on RHEL/CentOS 6]
# nano /etc/yum.repos.d/MariaDB.repo
[mariadb]
name = MariaDB
baseurl = http://yum.mariadb.org/10.1/centos6-amd64
gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
gpgcheck=1

# yum -y install mariadb-server mariadb

Start, enable & check the status of MariaDB service on your system

[Start, enable & check the status of MariaDB service on systemd system RHEL/CentOS 7]
# systemctl start mariadb.service
# systemctl enable mariadb.service
# systemctl status mariadb.service

[Start, enable & check the status of MariaDB service on SysVinit system RHEL/CentOS 6]
# service mysqld start
# chkconfig mysqld on
# service mysqld status

3a) Set MySQL root password

By default there is no password for MySQL instant and you need to run the below command to set the root password for security reason. I advise you to secure MySQL installation using mysql_secure_installation method which will set root password and adjust other settings to make more secure.

[MariaDB Secure installation]
$ sudo mysql_secure_installation

NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB
      SERVERS IN PRODUCTION USE!  PLEASE READ EACH STEP CAREFULLY!

Enter current password for root (enter for none): Press Enter
OK, successfully used password, moving on...

Set root password? [Y/n] y
New password: 
Re-enter new password: 
Password updated successfully!
Reloading privilege tables..
 ... Success!

Remove anonymous users? [Y/n] y
 ... Success!

Disallow root login remotely? [Y/n] y
 ... Success!

Remove test database and access to it? [Y/n] y
 - Dropping test database...
 ... Success!
 - Removing privileges on test database...
 ... Success!

Reload privilege tables now? [Y/n] y
 ... Success!

Cleaning up...

All done!  If you've completed all of the above steps, your MariaDB
installation should now be secure.

Thanks for using MariaDB!

Magesh Maruthamuthu

Love to play with all Linux distribution

You may also like...