Skip to content

Instantly share code, notes, and snippets.

@dhargitai
Last active August 29, 2015 14:03
Show Gist options
  • Save dhargitai/f84113e699f3f78c19af to your computer and use it in GitHub Desktop.
Save dhargitai/f84113e699f3f78c19af to your computer and use it in GitHub Desktop.
Make sure you have these settings to be able to connect remotely (i.e. with MySQL Workbench of Sequel Pro) to your MySQL database in a Vagrant VM.
Don't run the mysql deamon with --skip-networking option and don't restrict it to
allow connections only from the VM. In order to do that, comment out
bind-address SOME-IP-ADDRESS
settings in /etc/my.cnf, or bind your host machine's IP address too.
Grant all privileges for the root user in mysql:
GRANT ALL ON *.* TO root@'%' IDENTIFIED BY 'root';
GRANT ALL ON *.* TO root@'localhost' IDENTIFIED BY 'root';
Enable port forwarding in /etc/ssh/sshd_config:
AllowTcpForwarding yes
Restart the sshd service and you're done:
service sshd restart
Now you should be able to connect to the MySQL database in your VM through SSH:
MySQL host: 127.0.0.1
Username: root
Password: root
SSH host: host-or-ip-of-your-vm
SSH user: vagrant
SSH pass: vagrant
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment