DEV Community

makitosan
makitosan

Posted on

Vagrant MySQL Port Forwarding Configuration

  • Ubuntu 16.04
  • MySQL 5.7
  • Vagrant 2.0.2

VAGRANT

EDIT Vagrantfile

Vagrant.configure("2") do |config|
  config.vm.network "forwarded_port", guest: 3306, host: 3306
end
Enter fullscreen mode Exit fullscreen mode

MySQL (guest)

EDIT /etc/mysql/mysql.conf.d/mysqld.cnf

bind-address            = 0.0.0.0
Enter fullscreen mode Exit fullscreen mode

GRANT PRIVILEGES

On the guest machine, login to local mysql server and execute the following sqls.

GRANT ALL PRIVILEGES ON *.* TO 'root'@'10.0.2.2' IDENTIFIED BY 'your_password' WITH GRANT OPTION;
FLUSH PRIVILEGES;
Enter fullscreen mode Exit fullscreen mode

TEST

mysql -uroot -p
Enter fullscreen mode Exit fullscreen mode

Top comments (0)