1

I am trying to install mysql-server in debian:buster using Dockerfile and shell script, when I run this command

apt install -y mysql-server and during the installation I need to enter the password and retype it as shown in the picture:

enter image description here

I did a little search and I found how to do it using here-string in this page Install MySQL on Ubuntu without a password prompt

so because I am using this command apt install -y mysql-server I did it like this:

debconf-set-selections <<< 'mysql-server mysql-server/root_password password your_password'
debconf-set-selections <<< 'mysql-server mysql-server/root_password_again password your_password'
apt-get -y install mysql-server

but when I run them I still get the same thing and I need to enter the password.

Here is my Dockerfile:

From debian:buster

COPY ./run.sh /

CMD bash /run.sh

and this is run.sh:

apt update
apt install -y nginx gnupg wget lsb-release
wget https://dev.mysql.com/get/mysql-apt-config_0.8.13-1_all.deb
printf "1\n1\n4\n" | dpkg -i mysql-apt-config_0.8.13-1_all.deb           //version selected is mysql-5.7
apt update
service nginx start
bash                                                                     //just to stay in the bash of container and don't quit from it.

by the way I am trying to install mysql-server from inside the bash of the container then I'll write the commands in my script.

and there is something weird as you can see in the picture above it's written :

Configuring mysql-community-server
----------------------------------

even that I am installing with this command apt-get -y install mysql-server not this

apt-get -y install mysql-community-server

So do you know what am I missing here?

Holy semicolon
  • 868
  • 1
  • 11
  • 27

1 Answers1

2

Use

shell> sudo debconf-set-selections <<< "mysql-community-server mysql-community-server/root-pass password mypassword"
shell> sudo debconf-set-selections <<< "mysql-community-server mysql-community-server/re-root-pass password mypassword"
shell> sudo DEBIAN_FRONTEND=noninteractive apt-get -y install mysql-server

Documentation

Aleksandr
  • 401
  • 3
  • 7