Creative crypter Creative crypter - 4 months ago 141
MySQL Question

Vagrant Box - Install MySql 5.7 using apt

I created a basic vagrant box based on ubuntu/trusty64.

When i "vagrant up" the machine and next "vagrant ssh" into it, everything is fine.

Next step would be to install latest mysql 5.7, so thats what i did:

wget http://dev.mysql.com/get/mysql-apt-config_0.7.3-1_all.deb
sudo dpkg -i mysql-apt-config_0.7.3-1_all.deb
sudo apt-get update
sudo apt-get install -y mysql-server


So it downloads configures etc... next an "interactive" shell appears, where are i am requested to type password and repeat.

MySql 5.7 is installed successfully in my machine...BUT:

I would like it to be installed during "vagrant up", thats why i modified Vagrantfile with:

config.vm.provision :shell, path: "bootstrap.sh"


In bootstrap.sh i added content:

wget http://dev.mysql.com/get/mysql-apt-config_0.7.3-1_all.deb
sudo dpkg -i mysql-apt-config_0.7.3-1_all.deb
sudo apt-get update
sudo apt-get install -y mysql-server


This fails completely... in console i can read it tries to configure mysql 5.5 and its dependencies.

But why?

If anybody could help with this issue, i would be really thankful.

Thanks and Greetings!

Answer

The reason why vagrant is installing 5.5 instead of 5.7 is because ubuntu/trusty version might be ubuntu 14.04, default mysql version for ubuntu 14.04 is mysql 5.5.

Below is a vagrant file which automatically installs mysql 5.7, but I have configured centos6 here. Feel free to change the os and set that to ubuntu/trusty. Just do

mysql57_config.vm.box = 'ubuntu/trusty64'

# -*- mode: ruby -*-
# vi: set ft=ruby :

Vagrant.configure("2") do |config|

  config.vm.define :mysql57 do |mysql57_config|
    mysql57_config.vm.box = 'centos6'
    mysql57_config.vm.box_url = 'https://dl.dropbox.com/u/7225008/Vagrant/CentOS-6.3-x86_64-minimal.box' 
    mysql57_config.vm.hostname = 'mysql57'
    mysql57_config.vm.provider :virtualbox do |vb|
        vb.customize ["modifyvm", :id, "--memory", "1024", "--cpuexecutioncap", "60"] 
    end
    mysql57_config.vm.network "public_network" 
    mysql57_config.vm.provision "shell", path: "./provision.sh"
   end

end

provision.sh

rpm -qa|grep mysql-community-release && exit 0 || {
    yum -y install http://dev.mysql.com/get/mysql-community-release-el6-5.noarch.rpm
    yum-config-manager --enable mysql57-community-dmr
    yum -y install mysql-server mysql-client
        #yum -y install http://www.percona.com/downloads/percona-release/percona-release-0.0-1.x86_64.rpm
    #yum -y install percona-xtrabackup percona-toolkit
    service mysqld start
}