‹‹

Setting up MariaDB on Arch Linux

Oct 15, 2021

Read time: 1 minute

Arch Linux MariaDB docs

MariaDB is a reliable, high performance and full-featured database server which aims to be an ‘always Free, backward compatible, drop-in’ replacement of MySQL. Since 2013 MariaDB is Arch Linux’s default implementation of MySQL.

Install

$ sudo pacman -S mariadb

Setup the data directory

$ sudo mariadb-install-db --user=mysql --basedir=/usr --datadir=/var/lib/mysql

Start mariadb.service

$ systemctl start mariadb.service
$ systemctl enable mariadb.service

Add user

In the below example, the user monty with some_pass as password is being created, then granted full permissions to the database mydb:

$ sudo mysql -u root -p

MariaDB> CREATE USER 'monty'@'localhost' IDENTIFIED BY 'some_pass';
MariaDB> GRANT ALL PRIVILEGES ON mydb.* TO 'monty'@'localhost';
MariaDB> FLUSH PRIVILEGES;
MariaDB> quit

Logging into MariaDB

mysql -u //user_name// -p -h //ip_address// //db_name//

Eg:

mysql -u username -ppassword -h localhost database_name