Solved

Can't get Heidsql to connect to mysql on ubuntu

Posted on 2013-11-26
17
2,845 Views
Last Modified: 2013-11-27
I setup a LAMP server running on Ubuntu 12.4. I'm new to Linux. For some reason I can't get Heidisql to connect to mysql on my Ubuntu box. This is a fresh install. I can connect to phpmyadmin. The error I'm getting is: SQL Error (2003) in statement #0: Can't connect to MYSQL server on 'IP ADDRESS' (10061)
0
Comment
Question by:rraymond1130
  • 9
  • 8
17 Comments
 
LVL 19

Expert Comment

by:xterm
ID: 39678074
You need to edit the config file and replace the string "IP ADDRESS" with the actual IP address of your MySQL server.
0
 

Author Comment

by:rraymond1130
ID: 39678153
Which config file are you talking about? Remember I'm new to Linux.
0
 
LVL 19

Expert Comment

by:xterm
ID: 39678192
Sorry, I didn't realize you were using the Windows GUI for Heidisql.

In the Heidi Session manager screen, what does it say in the box "Hostname/IP"?
0
Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

 

Author Comment

by:rraymond1130
ID: 39678470
I'm using the IP address of the linux server
0
 
LVL 19

Expert Comment

by:xterm
ID: 39678504
Are you running a firewall on the Ubuntu box?

Please run on the Linux machine:

  /sbin/iptables -nL
0
 
LVL 19

Expert Comment

by:xterm
ID: 39678510
http://dev.mysql.com/doc/refman/5.6/en/can-not-connect-to-server.html

"The error (2003) Can't connect to MySQL server on 'server' (10061) indicates that the network connection has been refused. You should check that there is a MySQL server running, that it has network connections enabled, and that the network port you specified is the one configured on the server."

This definitely looks like a firewall related issue to me.
0
 

Author Comment

by:rraymond1130
ID: 39678553
This is what I get from the command above:
Chain INPUT (policy ACCEPT)
target     prot opt source               destination

Chain FORWARD (policy ACCEPT)
target     prot opt source               destination

Chain OUTPUT (policy ACCEPT)
target     prot opt source               destination
0
 
LVL 19

Expert Comment

by:xterm
ID: 39678598
Okay, so looks like no firewall.

From the Windows machine, please open cmd.exe (a DOS terminal window) and type the following:

c:\> telnet 1.2.3.4 3306

(substitute 1.2.3.4 with the IP of your Linux MySQL server)
0
 

Author Comment

by:rraymond1130
ID: 39678669
Connecting To 1.1.1.1 ...Could not open connection to the host, on port 3306
: Connect failed
0
 
LVL 19

Expert Comment

by:xterm
ID: 39678748
Okay, so your Linux box may not be listening for remote connections for whatever reason.

Please do from the Ubuntu machine and show me the result:

netstat -na | grep :3306
0
 

Author Comment

by:rraymond1130
ID: 39678858
netstat -na | grep :3306
tcp        0      0 127.0.0.1:3306          0.0.0.0:*               LISTEN
0
 
LVL 19

Expert Comment

by:xterm
ID: 39678876
Okay, please open /etc/my.cnf and find the line "bind address" and change it from 127.0.0.1 to 0.0.0.0

Then you will need to restart MySQL (as root):

/etc/init.d/mysql restart

The problem is that by default on Debian/Ubuntu, MySQL by default is only set up for local connections and doesn't listen on any other interface than localhost.

After you restart MySQL, Heidisql will connect fine.
0
 

Author Comment

by:rraymond1130
ID: 39679101
OK:

SQL Error (1130) in statement#0: Host 'my pc ip address' is not allowed to connect to this MySQL server.

Sounds like we have to give my ip permission to connect. I do remember having to do this on my Hostmonster account, but I was able to do that through the cpanel.
0
 

Author Comment

by:rraymond1130
ID: 39679110
I had to add my ip address into the Remote MySql Database, in order to use heidisql with my hostmonster MySQL. What would be the equivalent in this situation?
0
 
LVL 19

Expert Comment

by:xterm
ID: 39679115
Yes, you can do that in the mysql.db table through phpmyadmin.
0
 
LVL 19

Accepted Solution

by:
xterm earned 500 total points
ID: 39679125
Remember to reload mysql (or flush privileges) after you've added the entry to permit your host.
0
 

Author Closing Comment

by:rraymond1130
ID: 39680750
xterm thanks for your help. I will document all of this.
0

Featured Post

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

SSH (Secure Shell) - Tips and Tricks As you all know SSH(Secure Shell) is a network protocol, which we use to access/transfer files securely between two networked devices. SSH was actually designed as a replacement for insecure protocols that sen…
Linux users are sometimes dumbfounded by the severe lack of documentation on a topic. Sometimes, the documentation is copious, but other times, you end up with some obscure "it varies depending on your distribution" over and over when searching for …
Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…

821 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question