MySQL is a well known free, open-source relational database service, and it's great. MariaDB is just MySQL (a fork of it), but better.
Install MariaDB
sudo apt install mariadb-server
Secure Install/Setup
sudo mysql_secure_installation
Run the above command, and follow the instructions, if you don't want to then follow mine.
Press enter for the current password, and again when asked if you want to set a root password. Enter the password, then press enter for everything else.
Create Admin user
sudo mysql
GRANT ALL ON *.* TO 'admin'@'localhost' IDENTIFIED BY '<DESIRED_PASSWORD>' WITH GRANT OPTION;
FLUSH PRIVILEGES;
exit;
Test it works
Simply try logging in as the admin account.
mysql -u admin -p
It should ask for a password, so enter your DESIRED_PASSWORD, and if you get mysql access, it's successful.
(Optional) Make it easier to access on command line
If you're working with a terminal, when calling mysql
you'll need to enter a password each time. You can store the passwordwith a special .cnf file, making it faster to get into writing SQL.
Create/Edit the file with your editor of choice (mine's vim)
vim ~/.my.cnf
Add the following, with your credentials
[mysql]
user=<USERNAME>
password=<PASSWORD>
The above can be used for mysqldump, mysqladmin, and others too, by replacing the [mysql]
block, with the related. e.g. [mysqldump]
.