Solved

Can't get Heidsql to connect to mysql on ubuntu

Posted on 2013-11-26
17
2,939 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

 

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

Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

Question has a verified solution.

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

I am a long time windows user and for me it is normal to have spaces in directory and file names. Changing to Linux I found myself frustrated when I moved my windows data over to my new Linux computer. The problem occurs when at the command line.…
Setting up Secure Ubuntu server on VMware 1.      Insert the Ubuntu Server distribution CD or attach the ISO of the CD which is in the “Datastore”. Note that it is important to install the x64 edition on servers, not the X86 editions. 2.      Power on th…
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…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

691 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