Mysql – Share the database between vmware guest and host

mac os xMySQLvmwarewindows

I wanna Access the MySQL Database founded in Windows 10 from VMware Workstation MAC OS X guest and give the guest ( MAC in VMware ) only permissions to just one database from the host (Windows 10),

I mean I want the Mac guest can access to one database from the host (NOT For ALL Databases).

I am connected in the guest by bridge network adapter.
I know I must do a change in /Applications/XAMPP/xamppfiles/etc/my.cnf but don't know what. ( I am using XAMPP 7.1.6, it's doesn't have bind_address ).

I want the database always up in my machine ( Windows 10 ) and when I run the VMware mac guest ( MAC ) so the guest can access to this database.

( I mean I want the database to be accessed in the host ( although when VMware is off ) .

I have already made a database in PhpMyAdmin in the host ( Windows 10 ), How can I access to just this database from the MAC guest in the VMware.

I wanna mention I don't want to give permissions to this database to another computers in my Network, or another computers that have my IP Address.

I appreciate any help. Thanks.

Best Answer

You have to comment out the single line in the `my.cnf:

 bind_address = 127.0.0.1

By default mysql server listen only on the localhost for security reason. When that line is commented, mysql server become listening on the all available interfaces because default value is bind_address = *. Now you can connect to the mysql from the host OS by IP-address of the VM.

To restrict guest access to the single database/schema you have to perform the next query:

GRANT ALL PRIVILEGES ON database.* 
   TO 'guestuser'@'1.2.3.4' 
   IDENTIFIED BY 'somepassword';

where 1.2.3.4 is an IP-address of your host OS.

If you have dynamically assigned IPs on your LAN then you have to allow connections from the whole subnet your IPs are belongs to:

GRANT ALL PRIVILEGES ON database.* 
   TO 'guestuser'@'192.168.%' 
   IDENTIFIED BY 'somepassword';

where 192.168.% means 192.168.0.0-192.168.255.255