2016-07-29 26 views
2

Ich habe eine grundlegende Vagrants Box basierend auf ubuntu/trusty64 erstellt.Vagrant Box - Installiere MySql 5.7 mit apt

Wenn ich die Maschine und den nächsten "vagrant ssh" in sie "vagrantieren", ist alles in Ordnung.

Nächster Schritt wäre neueste MySQL 5.7 zu installieren, so das ist, was ich tat:

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 

es also Downloads konfiguriert etc ... weiter eine „interaktive“ Shell angezeigt wird, wo ich aufgefordert werde zu geben Passwort und wiederholen.

MySql 5.7 ist erfolgreich in meinem Rechner installiert ... ABER:

Ich möchte es bei "Vagrant up" installiert werden, das ist, warum ich Vagrantfile mit geändert:

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

In Bootstrap .sh i hinzugefügt Inhalt:

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 

Das komplett versagt ... in der Konsole i lesen kann mySQL 5.5 und ihre Abhängigkeiten zu konfigurieren versucht.

Aber warum?

Wenn jemand mit diesem Problem helfen könnte, wäre ich wirklich dankbar.

Danke und Grüße!

UPDATE Fehlermeldung

==> default: There are no enabled repos. 
==> default: Run "yum repolist all" to see the repos you have. 
==> default: You can enable repos with yum-config-manager --enable <repo> 
==> default: sudo: yum-config-manager: command not found 
==> default: There are no enabled repos. 
==> default: Run "yum repolist all" to see the repos you have. 
==> default: You can enable repos with yum-config-manager --enable <repo> 
==> default: mysqld: unrecognized service 
The SSH command responded with a non-zero exit status. Vagrant 
assumes that this means the command failed. The output for this command 
should be in the log above. Please read the output to determine what 
went wrong. 
+0

Können Sie bitte vagrant Box ubuntu Version zur Verfügung stellen? – Jordon

+0

ist ist ubuntu/trusty64 (virtualbox, 20160714.0.0) –

Antwort

1

Der Grund, warum vagrant 5.5 statt 5.7 installiert ist, weil ubuntu/trusty Version Ubuntu 14.04 sein könnte, Standard-MySQL-Version für Ubuntu 14.04 MySQL 5.5 ist.

Unten ist eine vagrant Datei, die mysql 5.7 automatisch installiert, aber ich habe centos6 hier konfiguriert. Fühlen Sie sich frei, das Betriebssystem zu ändern und setzen Sie das auf Ubuntu/Trusty. Just do

mysql57_config.vm.box = 'ubuntu/trusty64'

Anleitung:

mkdir mysql-5-7

cd mysql- 5-7

Sobald Sie in mysql-5-7-Verzeichnis hinzufügen, diese beiden Dateien, Vagrantfile und bootstrap.sh Datei

Vagrantfile

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

# All Vagrant configuration is done below. The "2" in Vagrant.configure 
# configures the configuration version (we support older styles for 
# backwards compatibility). Please don't change it unless you know what 
# you're doing. 
Vagrant.configure(2) do |config| 
    # The most common configuration options are documented and commented below. 
    # For a complete reference, please see the online documentation at 
    # https://docs.vagrantup.com. 

    # Every Vagrant development environment requires a box. You can search for 
    # boxes at https://atlas.hashicorp.com/search. 
    config.vm.box = "centos/7" 
    config.vm.hostname = "mysql57" 
    config.vm.provision "shell", path: "bootstrap.sh" 
    config.vm.define "mysql57" do |mysql57| 
    end 

    # Disable automatic box update checking. If you disable this, then 
    # boxes will only be checked for updates when the user runs 
    # `vagrant box outdated`. This is not recommended. 
    # config.vm.box_check_update = false 

    # Create a forwarded port mapping which allows access to a specific port 
    # within the machine from a port on the host machine. In the example below, 
    # accessing "localhost:8080" will access port 80 on the guest machine. 
    # config.vm.network "forwarded_port", guest: 80, host: 8080 

    # Create a private network, which allows host-only access to the machine 
    # using a specific IP. 
    config.vm.network "private_network", ip: "192.168.33.10" 

    # Create a public network, which generally matched to bridged network. 
    # Bridged networks make the machine appear as another physical device on 
    # your network. 
    # config.vm.network "public_network" 

    # Share an additional folder to the guest VM. The first argument is 
    # the path on the host to the actual folder. The second argument is 
    # the path on the guest to mount the folder. And the optional third 
    # argument is a set of non-required options. 
    # config.vm.synced_folder "../data", "/vagrant_data" 

    # Provider-specific configuration so you can fine-tune various 
    # backing providers for Vagrant. These expose provider-specific options. 
    # Example for VirtualBox: 
    # 
    # config.vm.provider "virtualbox" do |vb| 
    # # Display the VirtualBox GUI when booting the machine 
    # vb.gui = true 
    # 
    # # Customize the amount of memory on the VM: 
    # vb.memory = "1024" 
    # end 
    # 
    # View the documentation for the provider you are using for more 
    # information on available options. 

    # Define a Vagrant Push strategy for pushing to Atlas. Other push strategies 
    # such as FTP and Heroku are also available. See the documentation at 
    # https://docs.vagrantup.com/v2/push/atlas.html for more information. 
    # config.push.define "atlas" do |push| 
    # push.app = "YOUR_ATLAS_USERNAME/YOUR_APPLICATION_NAME" 
    # end 

    # Enable provisioning with a shell script. Additional provisioners such as 
    # Puppet, Chef, Ansible, Salt, and Docker are also available. Please see the 
    # documentation for more information about their specific syntax and use. 
    # config.vm.provision "shell", inline: <<-SHELL 
    # sudo apt-get update 
    # sudo apt-get install -y apache2 
    # SHELL 
end 

Bootstrap sind.sh

sudo yum install -y wget 
wget https://dev.mysql.com/get/mysql57-community-release-el7-8.noarch.rpm 
sudo yum install -y mysql57-community-release-el7-8.noarch.rpm 
sudo yum -y update 
sudo yum -y install mysql-server 
sudo systemctl start mysqld 
sudo systemctl enable mysqld 
MYSQL_TEMP_PWD=`sudo cat /var/log/mysqld.log | grep 'A temporary password is generated' | awk -F'[email protected]: ' '{print $2}'` 
mysqladmin -u root -p`echo $MYSQL_TEMP_PWD` password 'Passw0rd!' 
cat <<EOF> .my.cnf 
[client] 
user=root 
password=Passw0rd! 
EOF 

Jetzt laufen Sie weiter unten Befehle: vagrant up vagrant ssh

Ones Sie in der Maschine sind zu mysql verbunden: zu mysql verbinden und unter Anmeldeinformationen bereitstellen ~~ user: root password: Passw0rd!

Irgendwo in/etc/sudoers (oder /etc/sudoers.d wenn es im Lieferumfang enthalten ist) müssen Sie

vagrant ALL=(ALL) NOPASSWD:ALL 
Defaults:vagrant !requiretty 
haben

ohne das, der vagrant ssh (ohne tty) scheitert auf mysteriöse Weise.

Wenn Sie mit MacOS arbeiten, schalten Sie die Firewall aus und sehen Sie, dass das funktioniert?

+1

ok danke für die antwort aber wo genau ist mysql 5.7 installiert? kannst du deine provision.sh teilen? –

+1

@Creativecrypter sorry dafür, aktualisiert, danke :) – Jordon

+0

hey da habe ich meine Frage mit Fehlercode aktualisiert, könnten Sie sich darauf beziehen? –