up vote 2 down vote favorite
share [fb]

I'm coding a bash script to automate the process of deploying VPS servers but I'm having some trouble while trying to install MySQL from either aptitude/apt-get or yum, this is what I have so far:

if [ "$OS" == 'centos' ]; then
    yum -y install  mysql-server > /dev/null 2>&1
elif [ "$OS" == 'ubuntu' ]; then
    aptitude -y install mysql-server > /dev/null 2>&1
fi

It seems that the script keeps running ad infinitum, I suspect the problem is because the mysql-server package seems to bring up a wizard to specify the MySQL root password, but I've no idea how to overcome or fill the password from within the script.

Does anyone know how I can work around this problem?

link|improve this question
feedback

1 Answer

up vote 5 down vote accepted

You can use the DEBIAN_FRONTEND environment variable.

DEBIAN_FRONTEND=noninteractive aptitude -y install mysql-server > /dev/null 2>&1

or if you will run more than 1 install you might want to add an export to the top of your script

export DEBIAN_FRONTEND=noninteractive
aptitude -y install mysql-server > /dev/null 2>&1
link|improve this answer
Thank you! Do you know how I can do the same under CentOS? – Alix Axel Jan 26 at 9:49
@Alix Not really and I don't have access to a CentOS box – Gert Jan 26 at 10:42
Linode has some great guides on lamp setup for a lot of linux flavors: library.linode.com/lamp-guides – Chris J. Lee Jul 18 at 21:07
feedback

Your Answer

 
or
required, but never shown

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