$ sudo apt-get update
And install MariaDB:
$ sudo apt-get install mariadb-server
Start and enable MariaDB
$ sudo systemctl enable mariadb
$ sudo systemctl start mariadb
Or
$ sudo service mariadb enable
$ sudo service mariadb start
Now we will set up our MariaDB, which is needed when we start MariaDB for the first time. Do the following command:
$ sudo mysql_secure_installation
You will be asked password, but just hit enter because there is no password when it is started for the first time.
Maybe you will be asked a new password, however, we will not use password for MariaDB here because we will set a new password later. So if you are asked a new password, just hit the enter to set empty password. If this is for a real server, you need to set a secure password.
Run the following command to log into MariaDB:
$ mysql -u root
MariaDB[none]> use mysql;
MariaDB[mysql]> update user set password=PASSWORD("root") where User='root';
MariaDB[mysql]> flush privileges;
MariaDB[mysql]> exit;
Now your password for the root of MariaDB is changed to "root". You can log-in to MariaDB this way:
$ mysql -u root -proot