Skip to content

Instantly share code, notes, and snippets.

@jfengq
Created June 18, 2016 07:38
Show Gist options
  • Save jfengq/5ff05c75c18a137c11dcda51945bbb21 to your computer and use it in GitHub Desktop.
Save jfengq/5ff05c75c18a137c11dcda51945bbb21 to your computer and use it in GitHub Desktop.
connect mysql outside vagrant box
1.修改vagrant配置文件
Vagrant.configure(2) do |config|
...
config.vm.network "forwarded_port", guest: 3306, host: 3306
...
end
2.修改vagrant box中mysql配置文件
sudo sed -i 's/bind-address.*/bind-address = 0.0.0.0/' /etc/mysql/my.cnf sudo service mysql restart
3.connect
Connection Method: Standard TCP/IP over SSH
SSH Hostname: 127.0.0.1:2222
SSH Username: vagrant
SSH Key File: /.vagrant/default/virtualbox/private_key
MySQL Hostname: 127.0.0.1
MySQL Server Port: 3306 (or whatever port you forwarded to)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment