Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. 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

I did try to install mysql-server on my Vagrant Ubuntu 12.04 LTS virtual machine. When I did so, the setup auto-starts. I can see this in the Vagrant output:

While not mandatory, it is highly recommended that you set a password ││ for the MySQL administrative "root" user.││││ If this field is left blank, the password will not be changed.││││ New password for the MySQL "root" user

After that the output text goes haywire — ± ├⎺ ⎼␊⎻┌▒␌␊ ┌␋␉⎽─┌␋├␊3-0 3.7.9-2┤␉┤┼├┤1 (┤⎽␋┼± ... — but is rather lengthy and full of green and red colors, so I believe the rest of the install is completing.

But I can confirm the lack of install after:

sudo apt-get install --just-print mysql-server-5.5 
...
The following NEW packages will be installed:
  mysql-server-5.5

How can I send the right signals through a shell script to configure the MYSQL server? Or if I cannot, how can I stop the automatic launching of the configuration or kill the setup once launched while still having the package installed?

share|improve this question
    
If the rest of the install is completing, it would not allow you to install again. Have you tried setting up a password before installation? – Anthon Jul 29 '14 at 16:29
    
@Anthon Sorry I do not think I explained this well in my post: I can manually configure all of this, but my goal is to automate as much of my setup as possible. And I have many steps after this that depend on mysql being installed (installing rvm for instance). – Sam Jul 29 '14 at 16:32
    
Unless the problems are caused by an unclean system (try to install in a clean virtual machine setup) this sounds like a problem with the package itself. In such cases I have sometimes patched the installation file (not a complete rebuild, just extract/change/put-together) and served it from a local repository. – Anthon Jul 29 '14 at 16:40
    
@Anthon :/ I was hoping to find a solution like either a) A MYSQL server package exists that does not auto-launch the configuration wizard or b) there was a bash-y way to trap these kinds of launches (apt-get install mysql-server | some_trap_cmd >> some.file). Sounds like maybe no such thing exists? – Sam Jul 29 '14 at 16:46
    
The problem is that apt-get runs scripts within the installer file, you are not going to catch a trap in those unless you patch the scripts. You could also take a look at the 5.6 mysql and install it from launchpad, but that could create more trouble pulling in all of the dependencies, but maybe the installation problems are gone. – Anthon Jul 29 '14 at 17:33
up vote 25 down vote accepted

You can set the MySQL root password in your bootstrap file by adding debconf-set-selections commands before running your apt-get install:

#!/usr/bin/env bash

debconf-set-selections <<< 'mysql-server mysql-server/root_password password MySuperPassword'
debconf-set-selections <<< 'mysql-server mysql-server/root_password_again password MySuperPassword'
apt-get update
apt-get install -y mysql-server

I presume this to work on any Debian based system. I use it everyday, box is built completely automatically.

share|improve this answer
1  
Awesome! I didn't know this command – AlvaroAV Sep 26 '14 at 20:32
1  
I didn't debconf-set-selections existed. This worked perfectly. Thank you! – Sam Feb 4 '15 at 13:32

You might want to look into Puppet - it is excellent for installing and configuring software automatically. There's also a MySQL module, but I haven't tried it.

share|improve this answer

Your Answer

 
discard

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.