Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

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?

share|improve this question
add comment

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
share|improve this answer
    
Thank you! Do you know how I can do the same under CentOS? –  Alix Axel Jan 26 '11 at 9:49
    
@Alix Not really and I don't have access to a CentOS box –  Gert Jan 26 '11 at 10:42
1  
Linode has some great guides on lamp setup for a lot of linux flavors: library.linode.com/lamp-guides –  chrisjlee Jul 18 '11 at 21:07
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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