Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
mysql + vagrant + remote access
username: vagrant
password: vagrant
sudo apt-get update
sudo apt-get install build-essential zlib1g-dev git-core sqlite3 libsqlite3-dev
sudo aptitude install mysql-server mysql-client
sudo nano /etc/mysql/my.cnf
bind-address =
mysql -u root -p
use mysql
GRANT ALL ON *.* to root@'' IDENTIFIED BY 'jarvis';
sudo /etc/init.d/mysql restart
# -*- mode: ruby -*-
# vi: set ft=ruby : do |config| = "lucid32"
config.vm.box_url = ""
#config.vm.boot_mode = :gui
# Assign this VM to a host-only network IP, allowing you to access it
# via the IP. Host-only networks can talk to the host machine as well as
# any other machines on the same network, but cannot be accessed (through this
# network interface) by any external networks.
# :hostonly, ""
# Assign this VM to a bridged network, allowing you to connect directly to a
# network using the host's network device. This makes the VM appear as another
# physical device on your network.
# :bridged
# Forward a port from the guest to the host, which allows for outside
# computers to access the VM, whereas host only networking does not.
# config.vm.forward_port 80, 8080
config.vm.forward_port 3306, 3306 :hostonly, ""
Copy link

ttakamoto commented Mar 6, 2014

Really nice. Thanks for sharing.

Copy link

storytime commented Oct 6, 2014

Will it work on host machine as mysql -u root -p ?

Copy link

herderwu commented Feb 27, 2015

I use this:

sudo nano /etc/mysql/my.cnf
bind-address =

use mysql;
update user set host='%' where user='root' and host='';
flush privileges;

sudo /etc/init.d/mysql restart

Copy link

uselessdev commented Dec 5, 2015

In ubuntu 15.04 the MySQL Server configure file is in:


Copy link

julestruong commented Mar 25, 2016

Not working for me, it is like i can't access to :3306 from outside the vagrant

Copy link

yerlikayao commented Apr 30, 2016 "forwarded_port",guest:3306, host:3306

Copy link

jmleroy commented Jun 2, 2016

Don't forget to connect to localhost and not to your VM's hostname.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment