Connecting to Vagrant [PuPHPet] MySql from host


Connecting to Vagrant [PuPHPet] MySql from host

Probably here with – I can’t connect to mysql on vagrant machine Yup I have been there

If you are php developer and are using vagrant you would want to use mysql tool to access the vagrant mysql server.

Here is the step by step procedure.

I will assume the PuPHPet configuration
First, get the user which can connect from any host

Log into your vagrant

vagrant ssh

Then open the mysql configuration file

vi /etc/mysql/my.cnf

And update the bind-address part to be This will allow address to be used from any host.
If you want to specifically access from some host only, then put IP over there.

Then being in your vagrant machine run

mysql -uroot -p123

This will be depending on if you have provided a password for root the default on puPHPet would ask password so you would have a password

After this allow root user to access everything from everywhere.. or you can create another user and grant that

mysql > GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '123';

Then to make the sql pickup the changes made so far

sudo service mysql restart

Then being on your host machine open your sequel pro – if you are on mac.. or other clients you would use for mysql.

Mysql Host:
Mysql user: root
Mysql Password: 123

SSH Host:
SSH Username: vagrant – this is the default one
SSH key -> point the key in puphpet/files/dot/ssh/id_rsa
SSH Port: 2222 – this is also the default ssh port forwarding, if you change this change it here too..

See how to Setting up vegrant machine from scratch here

Group by week mysql

You don’t have permission to access / on this server. Apache error

The superclass “javax.servlet.http.HttpServlet” was not found on the Java Build Path

AbstractSureFireMojo Class Missing Maven Surefire

Spring Data error: getOutputStream() has already been called for this response

No Persistence provider for EntityManager named Hibernate error

  1. John van Terheijden

    Why don’t you just ssh tunnel into the vm using the private key (puphpet/files/dot/ssh/id_rsa)? Then you don’t need to change or configurate anything – good practice for your prod servers too as it will increase security. Most GUIs will let you do his or you can use command line (

    1. gullele

      Thank you very much John, that is a good advice actually. I will change that, test it and will post another blog on that showing how I have done it using the my ssh config and stuff..

      Again, thanks!

Leave a Reply to John van Terheijden Cancel reply

Your email address will not be published. Required fields are marked *