I can install MYSQL on Ubuntu without prompts with the code below:
dbpass="mydbpassword"
export DEBIAN_FRONTEND=noninteractive
echo mysql-server-5.1 mysql-server/root_password password $dbpass | debconf-set-selections
echo mysql-server-5.1 mysql-server/root_password_again password $dbpass | debconf-set-selections
apt-get -y install mysql-server
The part with the debconf-set-selections I got somewhere online (could be here can't remember) and it has worked ok for me thus far. I'm not that much of an expert to understand how it works but it does.
However, I want to do the same thing for Percona. I've setup the apt package manager to deal with using apt-get for percona. So now my code is the following:
dbpass="dbpass" && export dbpass
export DEBIAN_FRONTEND=noninteractive
echo percona-server-server-5.5 percona-server-server-5.5/root_password password $dbpass | debconf-set-selections
echo percona-server-server-5.5 percona-server-server-5.5/root_password_again password $dbpass | debconf-set-selections
apt-get -y install percona-server-server-5.5
However, Percona installs but without a password as defined. I know I'm missing something in the debconf bit.
I'd appreciate some guidance here.
Thanks in advance.
you can always do normal installation and then script:
If you understand what is going on underneath the hood it makes it easier to debug and figure out why this isn't working.
When you install a debian package often times you get questions about licenses, passwords, locations, etc. All of those values are stored in debconf. If you are wanting to do an unattended installation you can preload those answers into debconf so you aren't prompted for those questions, since they are already answered.
The challenge comes when understanding how to properly answer those questions. To do this you first need to install the debconf-utils
apt install debconf-utils
next you need to manually install your package.
In my case I am installing the percona-xtradb-cluster-57 package.
After this has been installed you can get the selections that have been set by using the
deb-get-selections
tool.In the response you will see the selections that were set. In this case
You can now copy the values that you want to set. In my case I want automatically set the root password.
In your automated installation script you can now use the
debconf-set-selections
tool to automate setting the values for the root password question and the confirm root password question.Happy Automating!
Think I figured it out
Don't use
export DEBIAN_FRONTEND=noninteractive
. If the debconf entries are correct, then you won't be prompted anyway. If they are incorrect and you usenoninteractive
then the prompt will continue with a blank password.Since Percona 'hooks into' MySQL check that it installed correctly using
and you will know it is percona if you see something like
Then finally check the password was set correctly
EDIT: That said, for a newer version of percona, F21's answer worked for me. You can check the entries in
/var/cache/debconf/passwords.dat
The second part of the
debconf-prefix
should not contain the version number:For 5.6:
I actually found that the answer here install mysql on ubuntu without password prompt that suggested
export DEBIAN_FRONTEND=noninteractive apt-get -q -y install mysql-server
Worked and left me with a root user with no password, which is what I wanted.