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
Then open the mysql configuration file
And update the bind-address part to be 0.0.0.0. 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'; mysql > FLUSH PRIVILEGES;
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: 127.0.0.1
Mysql user: root
Mysql Password: 123
SSH Host: 127.0.0.1
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