Last Modified 2019.7.27

Install MariaDB on Ubuntu 18.04

sudo apt update
sudo apt install mariadb-server

If the installation is completed without errors, run the following command to set the root password. (Press the Enter key for the current password.)

sudo mysql_secure_installation

Even if you set a password, mysql --user = root - password mysql will generate an error. Let's check the plugin that the root user uses.

sudo mysql
use mysql
select user,host,plugin from mysql.user;

Set the root user to use the mysql_native_password plugin as follows.

update user set plugin='mysql_native_password' where user='root';
flush privileges;
exit

Restart MariaDB.

sudo service mariadb restart
mysql --user=root --password mysql

You can use MariaDB with the MySQL JDBC driver.

<!-- https://mvnrepository.com/artifact/mysql/mysql-connector-java -->
<dependency>
    <groupId>mysql</groupId>
    <artifactId>mysql-connector-java</artifactId>
    <version>5.1.48</version>
</dependency>
References