4

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:

https://stackoverflow.com/questions/8138636/install-mysql-on-ubuntu-natty-without-password-prompt-and-using-shell-variable-a

https://stackoverflow.com/questions/7739645/install-mysql-on-ubuntu-without-password-prompt

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

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'
1

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
1

Using Ansible:

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

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

Docker

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)

0

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, privacy policy and cookie policy

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