Ubuntu MySQL – Scripted Installation Guide

installationMySQLscriptingUbuntu

I need to write a script that will build my server from a fresh Ubuntu server install. Among things like Apache and PHP it needs to install MySQL. The only problem here is that when I install MySQL with apt-get, at some point the installation will bring up a dialog that allows me to type my root password. I.e., human interaction is required.

How can I bypass this screen during installation and avoid human interaction while still using apt-get to install MySQL?

Best Answer

You need to preseed the debconf database. debconf needs to be installed first before you try this.

The version of mysql and ubuntu could change the line:

echo mysql-server mysql-server/root_password select PASSWORD | debconf-set-selections
echo mysql-server mysql-server/root_password_again select PASSWORD | debconf-set-selections

For example you made need this instead:

echo mysql-server-5.0 mysql-server/root_password password PASSWORD | debconf-set-selections
echo mysql-server-5.0 mysql-server/root_password_again password PASSWORD | debconf-set-selections