0

I'm trying to execute the following script to install MySQL unattended.

"export DEBIAN_FRONTEND=noninteractive" isn't working - I still have to press enter a few times to get past the prompts.

AWS Image: Ubuntu Server 14.04 LTS (PV), SSD Volume Type - ami-d85e75b0

Any suggestions?

#!/bin/sh

sudo apt-get install libaio1

export DEBIAN_FRONTEND=noninteractive

# Install script for mysql database

sudo groupadd mysql
sudo useradd -r -g mysql mysql
sudo tar xvf mysql-server_5.6.21-1ubuntu12.04_amd64.deb-bundle.tar
if [ $? != 0 ];then echo "Unable to extract tar file."; exit 100; fi

sudo dpkg -i mysql-common_5.6.21-1ubuntu12.04_amd64.deb
if [ $? != 0 ];then echo "Unable to install package mysql-common."; exit 100; fi

sudo dpkg -i mysql-community-server_5.6.21-1ubuntu12.04_amd64.deb
if [ $? != 0 ];then echo "Unable to install package mysql-community-server."; exit 100; fi

sudo dpkg -i mysql-community-client_5.6.21-1ubuntu12.04_amd64.deb
if [ $? != 0 ];then echo "Unable to install package mysql-community-client."; exit 100; fi

sudo mv /etc/mysql/my.cnf my.cnf.in
if [ $? != 0 ];then echo "Unable to move /etc/mysql/my.cnf."; exit 100; fi

sudo sed -e s/127.0.0.1/0.0.0.0/g my.cnf.in | sudo tee /etc/mysql/my.cnf
if [ $? != 0 ];then echo "Unable to configure my.cnf."; exit 100; fi

#sudo rm -f my.cnf.in

sudo /etc/init.d/mysql restart
if [ $? != 0 ];then echo "Unable to restart mysql server."; exit 100; fi

exit 0

# Leave the last line empty, otherwise it can cause problems running the script
Stormy2021
  • 43
  • 1
  • 4

2 Answers2

0

Greetings I have not tried yet but I saw this tut a few weeks ago:

https://serversforhackers.com/video/installing-mysql-with-debconf

Alberto Garcia
  • 349
  • 2
  • 9
  • This is probably my own ignorance, but export DEBIAN_FRONTEND=noninteractive is not working for me, possibly because I am using dpkg instead of apt-get? When I try the apt-get route for mysql-server-5.6, I run into a series of other issues unrelated to the original question here. Also, "sudo debconf-get-selections | grep mysql-server" doesnt return anything for me, so I can't determine what selections I should be setting. – Stormy2021 Jun 30 '15 at 18:25
  • Maybe you need to sudo DEBIAN_FRONTEND : `sudo DEBIAN_FRONTEND=noninteractive` [link](http://serverfault.com/a/227194) – Alberto Garcia Jun 30 '15 at 19:21
  • as it relates to my script, would i do "sudo debian_frontend=noninteractive dpkg -i mysql-common_5.6.21-1ubuntu12.04_amd64.deb", etc? – Stormy2021 Jun 30 '15 at 19:33
0

Look, in manual man dpkg you can find set of options --force-confdef(force to keep default option without prompting) and --force-confold (force to keep old conf files)

So, final command will look like (depending what do you need):
sudo dpkg -i --force-confdef mysql-common_5.6.21-1ubuntu12.04_amd64.deb
or
sudo dpkg -i --force-confold mysql-common_5.6.21-1ubuntu12.04_amd64.deb

Try this way, it helped me in issue here. By the way, What dpkg is asking you?

Community
  • 1
  • 1
antonbormotov
  • 1,821
  • 2
  • 20
  • 32