1

I just set up a new LAMP server. I can connect to mysql through the terminal. My goal is to use MySQL workbench to connect via Standard TCP/IP, however I can only connect via Standard TCP/IP over SSH

Here's the error message I get from mysql workbench when I try to connect via Standard (TCP/IP):

Failed to Connect to MySQL at 12.34.56.78:3306 with user root

Can't connect to MySQL server on '12.34.56.78' (10061)

Other info

  • Linux version 2.6.32-37-generic-pae (buildd@vernadsky) (gcc version 4.4.3 (Ubuntu 4.4.3-4ubuntu5) ) #81-Ubuntu SMP Fri Dec 2 22:24:22 UTC 2011
  • mysql Ver 14.14 Distrib 5.1.41, for debian-linux-gnu (i486) using
    readline 6.1
  • OpenSSH_5.3p1 Debian-3ubuntu7, OpenSSL 0.9.8k 25 Mar 2009
  • I ssh into the server from putty on a windows 7 computer.

Any clues on how to connect via mysql workbench (I've opened the right ports on the firewall)?

1
  • On the server, what's the output of: sudo netstat -nplt | grep -i mysql Jan 6, 2012 at 7:42

3 Answers 3

5

You have to configure MySQL to accept connection from a remote host. Edit you my.cnf and set bind-addrees parameter as follows:

bind-address            = 0.0.0.0
5
  • Did you restart mysql after you made the change? Jan 6, 2012 at 7:42
  • just comment it out and restart
    – Sergio
    Jan 6, 2012 at 13:09
  • Yes I restarted, and I tried with bind-address being 0.0.0.0 and with it being commented out
    – user784637
    Jan 6, 2012 at 19:29
  • Just in case someone is wondering, this worked great for me. Thanks Wilmer! However, I think you may also need to make sure to GRANT ALL PRIVILEGES and what not.
    – AturSams
    Jul 14, 2014 at 17:40
  • Worth mentioning to check that you're updating the correct my.cnf file. As explained here stackoverflow.com/a/67656078/11277108 - if you're on a Mac and installed mysql via homebrew then the file paths have changed for M1 vs Intel. I spent ages getting nowhere because I was updating my old my.cnf file from when I had an Intel Mac...
    – Jossy
    May 14, 2023 at 21:54
2

IMHO you should try to isolate the problem. It would be great to be able to tell if you can connect to your remote MySQL server from the mysql client in the command line. So open a terminal in the same machine you use to run Workbench and type:

mysql -u root -p -h your.ip.add.ress

According to my experience it is most likely that you have a configuration problem in your server. The above command will let you know if something is wrong server side. If that's the case, lots of connection problems are related with anonymous account messing up with your authentication. If you have anonymous accounts set, you'll be better off without them.

For additional info on setting up initial accounts in MySQL Server, please read the section of the MySQL manual entitled Securing the Initial MySQL Accounts.

0

With this type of error, another possible cause is the firewall configuration. Even though that was apparently not the case in this instance, hopefully this will help someone else:

SSH connects over port 22 (by default). Since that type of connection works in your case, the firewall (if you have one) is allowing traffic on port 22.

If you connect using Standard TCP/IP, the connection runs (again by default) over port 3306. If the firewall does not allow traffic on that port, a standard connection would not work.

If you open your firewall to that port, open it only for IP addresses that are known-good. If you were to open the firewall to any IP address, hackers may discover the open port and try a brute force or other type of attack against your DB.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.