HiveBrain v1.2.0
Get Started
← Back to all entries
patternModerate

Install MariaDB 10 on Ubuntu without prompt and no root password

Submitted by: @import:stackexchange-dba··
0
Viewed 0 times
withoutinstallubuntupasswordrootandpromptmariadb

Problem

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.

Solution

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

Code Snippets

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('');"
[client]
user = root
password = s3kr1t

Context

StackExchange Database Administrators Q#59317, answer score: 17

Revisions (0)

No revisions yet.