Solved

Can't get Heidsql to connect to mysql on ubuntu

Posted on 2013-11-26
17
2,792 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
Comment Utility
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
Comment Utility
Which config file are you talking about? Remember I'm new to Linux.
0
 
LVL 19

Expert Comment

by:xterm
Comment Utility
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
 

Author Comment

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

Expert Comment

by:xterm
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 

Author Comment

by:rraymond1130
Comment Utility
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
Comment Utility
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
Comment Utility
netstat -na | grep :3306
tcp        0      0 127.0.0.1:3306          0.0.0.0:*               LISTEN
0
 
LVL 19

Expert Comment

by:xterm
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
Yes, you can do that in the mysql.db table through phpmyadmin.
0
 
LVL 19

Accepted Solution

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

Author Closing Comment

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

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Daily system administration tasks often require administrators to connect remote systems. But allowing these remote systems to accept passwords makes these systems vulnerable to the risk of brute-force password guessing attacks. Furthermore there ar…
Introduction We as admins face situation where we need to redirect websites to another. This may be required as a part of an upgrade keeping the old URL but website should be served from new URL. This document would brief you on different ways ca…
Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:
Connecting to an Amazon Linux EC2 Instance from Windows Using PuTTY.

728 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now