MySQL (actually MariaDB) Setup Guide



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

Create Admin user

sudo mysql
GRANT ALL ON *.* TO 'admin'@'localhost' IDENTIFIED BY 'password' WITH GRANT OPTION;
FLUSH PRIVILEGES;
exit;

Test it works

(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=
password=

The above can be used for mysqldump, mysqladmin, and others too, by replacing the [mysql] block