I have Ubuntu running in VMWare. I installed mysql 5 server and comment out bind-address and restarted the mysql server. I am now trying to connect to mysql but i cannot. I tried using 1) Code and 2) A gui app from MySql website. Both report it cannot access the server. What do i need to do to get this to connect?
2 Answers
A number of things could cause this (firewall, other inbound port blocking problems, VMWare NAT'ed without port forwarding, MySQL not listening on the correct interface / MySQL not running networking, incorrect MySQL grant...)
Things to consider:
- Is MySQL running and running with networking (you may need to specify a user/pass for these)?
mysqladmin --protocol=socket ping # check if accessible via UNIX socket mysqladmin --protocol=tcp ping # check if accessible via localhost TCP/IP mysqladmin --protocol=tcp --host=ipaddress ping # check if accessible via external IP (MySQL can be configured to listen on the loopback address only, it can also be configured to *skip-networking* entirely)
- Is the machine accessible from other machines? Run
nmap -sT -p 22,3306 ipaddress
from another machine, this will give an indication whether the machine is accessible on the SSH/MySQL ports or not. - If the VM is running in NAT networking mode (as opposed to bridged), then you'll need to ensure the correct ports are forwarded to the machine's real IP address, or otherwise use the NAT address (where accessible) for communicating
- Is a firewall on the VM, or the VM's host preventing access to port 3306 (the default MySQL port)? Check your firewall rules (iptables -L for iptables).
- If you're accessing the MySQL server via DNS, is DNS causing the problem? You can try connecting using the IP address instead of a hostname in this case to eliminate this possibility
- If logins are working on the machine, but permission is being denied remote machines, remember that MySQL performs access control using username, password and hostname (with wildcards permitted). You may need to adjust your grant tables.
I hope one/some these help you track down the problem!
Lockie
-
Great answer!
mysqladmin --protocol=tcp --host=ipaddress ping
failed (i changed ipaddress to the machine actual address). I have commented out the bind-address before posting. Right now I dont see the skip-networking and notice that could be a problem from google yesterday. Here is my current config which was the default + commenting out bind address pastie.org/742545– user274Dec 14, 2009 at 14:19 -
The last line of your config, "!includedir /etc/mysql/conf.d/" looks like a mistake (the exclamation mark). Otherwise the config runs okay on my machine.– LockieDec 14, 2009 at 14:42
-
$mysqladmin --protocol=tcp --host=192.168.100.129 ping --port=3306 mysqladmin: connect to server at '192.168.100.129' failed error: 'Host 'name-desktop.local' is not allowed to connect to this MySQL server'– user274Dec 14, 2009 at 14:50
-
"# Generated by iptables-save v1.3.8 on Mon Dec 14 06:52:22 2009 filter :INPUT ACCEPT [1782:1078946] :FORWARD ACCEPT [0:0] :OUTPUT ACCEPT [1490:81549] COMMIT # Completed on Mon Dec 14 06:52:22 2009 "Looks like the port is in the accept range. Weird. I googled and looked. There doesnt *seem to be a firewall. Maybe i am better off getting hosting from a free service online.– user274Dec 14, 2009 at 14:58
-
I tried your answer again on another distro and it help me find the problems perfectly and on a unfamiliar disto (and being inexperienced) i had everything working within the hour!– user274Feb 25, 2010 at 6:54
You can also do something like "sudo tcpdump port mysql" on the MySql server box and see if you get any packets when trying to connect from the remote client. That will help narrow down which side of the network the issue is on.