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