How to install and configure MariaDB in Linux

Home > Search > How-to
  by

Use apt-get or yum to install MariaDB.

[root@server1 ~]# apt-get install mariadb mariadb-server
[root@server1 ~]# yum install mariadb mariadb-server

 

Ensure MariaDB will automatically start if the system is rebooted.

[root@server1 ~]# chkconfig mariadb on

 

Enable MariaDB, start MariaDB, and then ensure MariaDB is active and running.

[root@server1 ~]# systemctl enable mariadb
[root@server1 ~]# systemctl start mariadb
[root@server1 ~]# systemctl status mariadb

 

Secure MariaDB.  There will be a series of prompts.  Create a password, remove the test database, do not allow remote connections.

[root@server1 ~]# mysql_secure_installation

 

When prompted to enter root password, do not enter root password, and press enter. 

Enter current password for root (enter for none):

 

When prompted to set root password, type Y and press enter. Type a new password. The password does not need to be the same a root system password.

Set root password? [Y/n]
New password:
Re-enter new password:

 

When prompted to remove the anonymous user, type Y and press enter.

Remove anonymous user? [Y/n]

 

When prompted to disable remote root login, type Y and press enter.

Disallow root login remotely? [Y/n]

 

When prompted to remove the test database, type Y and press enter.

Remove test database and access to it? [Y/n]

 

When prompted to reload the priviledge tables, type Y and press enter.

Reload priviledge tables now? [Y/n]

 

Type mysql -u root -p and press enter to connect to MariaDB. Type the password entered during the mysql_secure_installation.

[root@server1 ~]# mysql -u root -p
Enter password:

 

Type show databases; and press enter to view the databases.

MariaDB [(none)]> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
+--------------------+
3 rows in set (0.00 sec)

 

Type quit to disconnect from MariaDB.

MariaDB [(none)]> quit

 



Add a Comment




We will never share your name or email with anyone. Enter your email if you would like to be notified when we respond to your comment.




Please enter in the box below so that we can be sure you are a human.




Comments