mysqlbashubuntudebiandebconf

preconfigure an empty password for mysql via debconf-set-selections


I am setting up a bash script to automate the building of a LAMP environment.

I am using debconf-set-selections to set options before installing mysql, phpmyadmin, etc ...

It works mainly great. But the problem is that I have to set an empty password for mysql and it still asks for the password during installation even with the lines typed before :

echo "mysql-server-5.5  mysql-server/root_password  password" | debconf-set-selections
echo "mysql-server-5.5  mysql-server/root_password_again    password" | debconf-set-selections

Solution

  • The recommended approach for setting an empty password during mysql-server's package installation process using debconf-set-selections depends on the package version in hand.

    A fallback solution

    If all approaches fail, it's possible to circumvent the issue and implicitly leave the password blank by preventing debconf from asking the user for a password altogether. Unfortunately, this applies to all questions, rather than just the password-related ones.

    Here are two methods that achieve the desired result: