I need to install MariaDB server in Ubuntu without password prompt. For this purpose, I execute the following commands, but it doesn't gave me any progress. It again shows password prompt.

I used the following commands :

  export DEBIAN_FRONTEND=noninteractive
  echo mariadb-server-5.5 mariadb-server/root_password password mypass | debconf-set-selections
  echo mariadb-server-5.5 mariadb-server/root_password_again password mypass | debconf-set-selections
  sudo apt-get -y install mariadb-server

I also check some links in stack overflow, but it doesnot worked:



Please help me on this regard. Have any wrong with my code?

5 Answers 5


A mixture of the mysql/mariadb-Nameing has worked for me:

export DEBIAN_FRONTEND=noninteractive
debconf-set-selections <<< 'mariadb-server-5.5 mysql-server/root_password password rootpass'
debconf-set-selections <<< 'mariadb-server-5.5 mysql-server/root_password_again password rootpass'

Using Ansible:

- name: Configure MariaDB Installation
    name: mariadb-server
    question: "{{ item }}"
    vtype: password
    value: "{{ db_root_pass }}"
    - mysql-server/root_password
    - mysql-server/root_password_again
  register: configure_install

- name: Install MariaDB with custom configuration
    name: mariadb-server
    state: latest
    update_cache: true
  when: configure_install | success
  register: install_mariadb

I believe you just use the mysql commands as it's backwards-compatible:

echo 'mysql-server mysql-server/root_password password test
mysql-server mysql-server/root_password_again password test' > /root/src/debconf.txt
debconf-set-selections /root/src/debconf.txt


Put the following in your Dockerfile.

To set the root password to rootpass:

RUN ["/bin/bash", "-c", "debconf-set-selections <<< 'mariadb-server-10.3 mysql-server/root_password password rootpass'"]
RUN ["/bin/bash", "-c", "debconf-set-selections <<< 'mariadb-server-10.3 mysql-server/root_password_again password rootpass'"]
RUN apt-get -y install mariadb-server-10.3

Or, to set no/empty root password:

RUN DEBIAN_FRONTEND=noninteractive apt-get -y install mariadb-server-10.3

(note I'm installing MariaDB 10.3, not 5.5)


For me, in a clean debian 8.6, after installing and making useable sudo with

su <rootpassword><return>
apt-get -y install sudo
usermod -aG sudo <me>

shortening the above solutions to the following command worked:

sudo sh -c 'apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y mariadb-server'

Afterwords, the mariadb-root has an empty password.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.