How to install mysql-server in the Ubuntu server using shell script without being asked any configuration questions?

· · 2332 views · Solved

I am trying to install mysql-server in Ubuntu server using a shell script, when I run this command apt install -y mysql-server and during the installation I need to enter the password and retype again.

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.

0
1 Answer

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

0
Best answer

Please login or create new account to participate in this conversation.