Hi All. Today I had to access my MySQL Server that is running inside a vagrant virtual box. After a little research I found the best way to do so.

Check it out:

  1. Inside your Vagrant machine, open with your editor the my.cnf file (usually it’s in /etc/mysql/my.cnf or /etc/my.cnf);

    $ sudo nano /etc/mysql/my.cnf
  2. Now look for “bind-address = 127.0.0.1” and change it to “bind-address = 0.0.0.0”. This way you are enabling your MySQL Server to be accessed remotely (by networking);
  3. Access your mysql by terminal:

     mysql> -uYOUR_ROOT_USER -pYOUR_PASSWORD
  4. And run the command in your database:

     mysql> GRANT ALL PRIVILEGES ON *.* TO 'YOUR_ROOT_USER'@'YOUR_HOST_MACHINE_IP' IDENTIFIED BY 'ANY_PASSWORD' WITH GRANT OPTION;
  5. Restart your MySQL Server:

     $ sudo /etc/init.d/mysql restart