Skip to content

Instantly share code, notes, and snippets.

@beninada
Last active August 1, 2019 22:25
Show Gist options
  • Save beninada/9170b92dc43a4c3ab3e14cb11d9898f4 to your computer and use it in GitHub Desktop.
Save beninada/9170b92dc43a4c3ab3e14cb11d9898f4 to your computer and use it in GitHub Desktop.

Connect to MySQL running in Vagrant

Source: https://coderwall.com/p/yzwqvg/connect-to-mysql-in-vagrant-with-sequel-pro

First, vagrant ssh and add a user that can connect from anywhere.

mysql -u root -e "GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '' WITH GRANT OPTION; FLUSH PRIVILEGES;"

Next, find the address MySQL is bound to.

cat /etc/mysql/my.cnf | grep bind-address

This is the MySQL host you'll be connecting to.

We'll be using the SSH connection tab in Sequel Pro. The username is root. By default, no password is required.

Vagrant's default SSH settings are as follows:

  • SSH Host: 127.0.0.1
  • SSH User: vagrant
  • SSH Key: ~/.vagrant.d/insecureprivatekey
  • SSH Port: 2222

Enjoy!

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