Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Is there a way to pass the desired MYSQL password to the prompts in the apt-get install lamp-server^ package in a single command line?

Note: I tried finding the package repository to read up on it, but I can't find it.

share|improve this question
No. This must be done when you'll configure your database after installation. – muniz95 Mar 15 '14 at 18:37
@muniz95 Actually, if you read the answer below you'll see that this isn't the case. – Seth Mar 23 '14 at 0:10
Well, living and learning... – muniz95 Mar 24 '14 at 14:31
up vote 4 down vote accepted

You can preset the password:

sudo debconf-set-selections <<< 'mysql-server mysql-server/root_password password your_password'
sudo debconf-set-selections <<< 'mysql-server mysql-server/root_password_again password your_password'
sudo apt-get -y install lamp-server^

This is adapted from a SO Question which has a few variants on this idea.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.