How to Connect to MySQL Server (Host Machine) from VMWare (Virtual Machine)




Problem: I have an application in VMWare that needs to connect to MySQL database server in host machine. Both host machine and virtual machine are on the same server. How do I do it?

 

Solution: refer to the steps below …

  1. In host machine, one has to create a new MySQL User and assign privileges as below in Query prompt via phpMyAdmin or SQL editor:-
    CREATE USER 'username'@'localhost' IDENTIFIED BY 'password';
    GRANT ALL PRIVILEGES ON *.* TO 'username'@'localhost' WITH GRANT OPTION;
    CREATE USER 'username'@'%' IDENTIFIED BY 'password';
    GRANT ALL PRIVILEGES ON *.* TO 'username'@'%' WITH GRANT OPTION;
    FLUSH PRIVILEGES;
  2. Once done with all four queries, the virtual machine should able to connect with IP address, user name and password of database’s host machine, e.g.:-
    IP address: 192.168.0.59
    Port: 3306
    User: (username)
    Password: (Password)

Source: http://stackoverflow.com/questions/1559955/host-xxx-xx-xxx-xxx-is-not-allowed-to-connect-to-this-mysql-server