After creating a new mySQL server within an Ubuntu guest OS running on VirtualBox, (how is that for a mouthful?) I wanted to connect to the server with HeidiSQL, my toolbox of choice when dealing with basic SQL operations. I expect that I would have the same problems attempting to connect with similar client software, such as mySQL Workbench or PHPmyAdmin.
The symptoms of the problem showed up in an error message, generated by HeidiSQL:
Connect Error (2003) Can‘t connect to MySQL server on ‘192.168.219.107‘ (10061)
So, more or less in order, I did the following:
1. Create a mySQL user with an identical name and password as the Ubuntu user account. To connect to mySQL, you need to have two valid accounts: a.) a valid Linux user account, and b.) a valid mySQL user account. On Ubuntu, these need to be same….because you only get one chance to pass through a name and password when logging into a server from HeidiSQL. This is done by logging into the mySQL client on the Ubuntu box, and performing the following:
GRANT ALL PRIVILEGES ON *.* TO ‘username‘@’%’ IDENTIFIED BY ‘password‘ WITH GRANT OPTION;
Note that the both the user names and password are case-sensitive, and the mySQL user’s name and password must be identical to the ubuntu user’s name and password for Heidi to be able to log in.
Restart the machine.
sudo shutdown -r now
This reloads everything, including the mySQL daemon so that it listens on the new IP address.
That’s it. You should be able to log in with Heidi now.
1. You could probably leave the default networking setting in place, (it is NAT), and the VM will be assigned a NAT address along the lines of 10.0.2.15. You’d still probably want to edit the mySQL file to reflect this address, and you might also want to make sure that you forward the mySQL port 3306. I just haven’t tested this, so that I can’t vouch that it will work.
2. Of course, in a production situation, you’ll want to choose a fixed IP address for the network address. This might involve your main router and firewall, so you may need to discuss this with the sys admins.
Anyway, now that I’ve actually got this thing running…I’ve got to get back to mySQL!