Ubuntu – How to Install MariaDB 10 Without Prompt and No Root Password

mariadbUbuntu

Pretty much the same as this question but I don't want to have a root password (this is just a dev machine).

Here's what I've got:

export DEBIAN_FRONTEND=noninteractive
sudo debconf-set-selections <<< 'mariadb-server-10.0 mysql-server/root_password password PASS'
sudo debconf-set-selections <<< 'mariadb-server-10.0 mysql-server/root_password_again password PASS'
sudo apt-get install -y mariadb-server

This will install MariaDB silently but it will set the root password to "PASS". If I delete that it does a weird partial install because it's still trying to prompt me.

Best Answer

In the link that Dimitar provided, the question itself hints at a solution - if you're putting this in a script, you could add the SET PASSWORD line with an empty password.

export DEBIAN_FRONTEND=noninteractive
sudo debconf-set-selections <<< 'mariadb-server-10.0 mysql-server/root_password password PASS'
sudo debconf-set-selections <<< 'mariadb-server-10.0 mysql-server/root_password_again password PASS'
sudo apt-get install -y mariadb-server
mysql -uroot -pPASS -e "SET PASSWORD = PASSWORD('');"

That said, I recommend that you keep using passwords, even for dev environments. As suggested on a related serverfault question, you could add lines to your my.cnf which contain the password, meaning that you can still simply fire up mysql by typing 'mysql':

[client]
user = root
password = s3kr1t