2

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?

1 Answer 1

6

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
3
  • Thank you! Do you know how I can do the same under CentOS?
    – Alix Axel
    Jan 26, 2011 at 9:49
  • @Alix Not really and I don't have access to a CentOS box
    – Gert
    Jan 26, 2011 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, 2011 at 21:07

This site is temporarily in read-only mode and not accepting new answers.

Not the answer you're looking for? Browse other questions tagged .