LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 03-01-2005, 08:59 PM   #1
lsimon4180
Member
 
Registered: Oct 2004
Location: Chicago, IL
Distribution: Fedora Core 2
Posts: 101

Rep: Reputation: 15
cannot connect to mysql database externally


Hi,

Im running Fedora 2 and Im trying to make a remote connect the mysql db running on the server but it keeps on saying:

Could not open connection to host on port 3306.

I am able to make a connection by doing telnet localhost 3306 on the server just not externally so i know its running.

I even added a rule in iptables:

iptables -A INPUT -p tcp --dport 3306 -j ACCEPT

also opened the port on my firewall.


Any suggestions?
 
Old 03-01-2005, 09:12 PM   #2
Matir
LQ Guru
 
Registered: Nov 2004
Location: San Jose, CA
Distribution: Debian, Arch
Posts: 8,507

Rep: Reputation: 128Reputation: 128
Is the server listening on the external IP address as well as localhost? Many are configured only to listen to localhost.
 
Old 03-01-2005, 09:25 PM   #3
lsimon4180
Member
 
Registered: Oct 2004
Location: Chicago, IL
Distribution: Fedora Core 2
Posts: 101

Original Poster
Rep: Reputation: 15
great question, how would i tell and if not how would i configure it?
 
Old 03-01-2005, 09:47 PM   #4
lsimon4180
Member
 
Registered: Oct 2004
Location: Chicago, IL
Distribution: Fedora Core 2
Posts: 101

Original Poster
Rep: Reputation: 15
This is a copy of my my.cnf file:

[root@baguh etc]# vi my.cnf
[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock

[mysql.server]
user=mysql
basedir=/var/lib

[safe_mysqld]
err-log=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid

I even tried putting in:

bind-address = 127.0.0.1
port = 3306

and tried my local net IP and external and restarted mysql but no dice
 
Old 03-01-2005, 09:54 PM   #5
Matir
LQ Guru
 
Registered: Nov 2004
Location: San Jose, CA
Distribution: Debian, Arch
Posts: 8,507

Rep: Reputation: 128Reputation: 128
You do not want to bind it to 127.0.0.1. You can use "netstat" to see if it's listening on both 127.0.0.1 and (at least) *:3306.
 
Old 03-01-2005, 10:01 PM   #6
lsimon4180
Member
 
Registered: Oct 2004
Location: Chicago, IL
Distribution: Fedora Core 2
Posts: 101

Original Poster
Rep: Reputation: 15
netstat shows nothing for the 3306, just a few httpd prcocess open.

nmap shows the following:

3306/tcp open mysql

I removed the bind-address and port variables from the file (like it was originally)

Thanks,

Lenny
 
Old 03-01-2005, 10:04 PM   #7
lsimon4180
Member
 
Registered: Oct 2004
Location: Chicago, IL
Distribution: Fedora Core 2
Posts: 101

Original Poster
Rep: Reputation: 15
I try telnet locahost 3306 I get:

[root@xxxxx root]# telnet localhost 3306
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
(
3.23.58o>'Ht29e,

Then after about 5 sec the Connection closed by foreign host.

not sure if there is something else wrong.

When i telnet to it locally and then run netstat i see the established connection
 
Old 03-02-2005, 09:36 AM   #8
Matir
LQ Guru
 
Registered: Nov 2004
Location: San Jose, CA
Distribution: Debian, Arch
Posts: 8,507

Rep: Reputation: 128Reputation: 128
The point is, you keep using localhost: but your problems are not with localhost, but external. You need to try connecting to the EXTERNAL ip of the machine, not 127.0.0.1.
 
Old 03-02-2005, 09:46 AM   #9
lsimon4180
Member
 
Registered: Oct 2004
Location: Chicago, IL
Distribution: Fedora Core 2
Posts: 101

Original Poster
Rep: Reputation: 15
Oh it am trying to connect to my external IP from a different location but it just hangs on:

telnet external_IP 3306
Trying external_IP...

router, firewall are all allowing 3306 connections
 
Old 03-02-2005, 10:15 AM   #10
Matir
LQ Guru
 
Registered: Nov 2004
Location: San Jose, CA
Distribution: Debian, Arch
Posts: 8,507

Rep: Reputation: 128Reputation: 128
But mysql is apparently not listening for external connections. Make sure there is no "skip-networking" entry in my.cnf. Also check for a bind-address = 127.0.0.1: there is one by default on most installs.
 
Old 03-02-2005, 10:26 AM   #11
lsimon4180
Member
 
Registered: Oct 2004
Location: Chicago, IL
Distribution: Fedora Core 2
Posts: 101

Original Poster
Rep: Reputation: 15
THis is the contents of the my.cnf file:

[root@baguh etc]# vi my.cnf
[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock

[mysql.server]
user=mysql
basedir=/var/lib

[safe_mysqld]
err-log=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid

Should I add the bind-address to my external IP or not?
 
Old 03-02-2005, 11:01 AM   #12
berrance
Member
 
Registered: Aug 2004
Location: Hull - England
Distribution: Ubunto and slowly switching to debian
Posts: 308

Rep: Reputation: 30
make sure your router is forwarding the mysql port to the local ip address on which the sql server is hosted and set my sql to lisen on the local ip address as from your router it will be accessing the loacal ip

also can you access it localy? and does your isp block port 3306?

and just out of curiosity how come you want to access your sql data base externaly? if its on a web site the same server i hosting set the PHP script to use the local ip and not external as with apache sql and php it reads the sql serverside and not client side so ther is no point in having the port open if thats what you are doing
 
Old 03-02-2005, 11:09 AM   #13
lsimon4180
Member
 
Registered: Oct 2004
Location: Chicago, IL
Distribution: Fedora Core 2
Posts: 101

Original Poster
Rep: Reputation: 15
It does work locally telnet localhost 3306 but not externally telnet ext_ip 3306, My ISP is not blocking that port, cuz i checked.

I have several customers that need enternal access (just temporarily) so I would like to know how to set this up. THey are using phpmaker and need to connect to the mysql server so they can work with phpmaker and there db.

the router is forwarding the port to the local IP of the server now how to I set mysql to listen to the local IP? do i add the following in the my.cnf file?

bind-address = 192.168.1.x

Thanks,

Lenny
 
Old 03-02-2005, 11:34 AM   #14
NoStop
Member
 
Registered: Feb 2005
Location: Canada
Distribution: Debian Etch - Enlightenment E17
Posts: 116

Rep: Reputation: 15
Have you considered using phpMyAdmin? That will give you an easy to use web access to your mysql databases, if all they need to do is edit, browse or backup their databases.

Cheers
 
Old 03-02-2005, 11:39 AM   #15
lsimon4180
Member
 
Registered: Oct 2004
Location: Chicago, IL
Distribution: Fedora Core 2
Posts: 101

Original Poster
Rep: Reputation: 15
Yep, they and myself are using it right now, but the program that they are using phpmaker doesnt manage the db its connects to it and generates php code.

Thanks,

Lenny
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Unable to connect to (working) mySQL database rcs1000 Linux - Software 1 10-16-2005 07:23 AM
cannot connect to mysql database from php rocordial Linux - Software 2 08-21-2005 02:05 PM
cannot connect to mysql database mrosati Linux - Software 19 07-15-2004 02:40 PM
Apache 1.3 - can't connect externally slightcrazed Linux - Software 2 02-03-2004 10:16 AM
vsftpd - Can't connect externally??? Xgkkp Linux - Networking 5 08-30-2003 12:50 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 02:48 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration