Install MySQL without a password prompt on Debian

when we are installing mysql using command on rpm based systems like Cent-OS then by default it sets root password blank, so if we want want to set mysql root password from backend using script or something then all we need to do is executing mysqladmin command to set password.

i.e mysqladmin -u root password YOUR_NEW_PASSWORD

but you can not do the same in debain systems because in that systems during installation its prompts for root password and re-enter root password. so here setting up root password from backend or installing mysql without password prompt is somewhat different.

Below are the commands to install mysql server without password prompt.

echo mysql-server mysql-server/root_password password PASSWORD | debconf-set-selections
echo mysql-server mysql-server/root_password_again password PASSWORD | debconf-set-selections
apt-get install -y mysql-server
Don't forget to replace PASSWORD with your actual password which you want to set for roor user.

you can simply plug this three lines in any script to install mysql-server with desired root password, it won't prompt you to enter root password.

If you face any problem then feel free to contact me.
 

 

No comments:

Post a Comment

Pages