LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 03-18-2004, 07:43 AM   #1
griffey
Member
 
Registered: Jan 2004
Location: East Central Illinois
Distribution: RHEL 4/5/6 and Fedora
Posts: 89

Rep: Reputation: 15
Problem connecting to MySQL


Hi folks,

I'm having a bit of a problem using a Mac OS sql client called CocoaMySQL.

I've set up a database on a test webserver using MySQL and PHP. I can look at those database tables (and edit them) from my OS X machine using the aforementioned Cocoa program.

Today I'm getting ready to move my stuff into production, but CocoaMySQL won't let me connect to the production websever. The PHP pages work fine and can create databases, tables, enter data, etc., but when I try to connect using CocoaMySQL I get a "Connection failed!" dialog box.

At first I thought it was a problem with having only granted privileges for the new sql user on localhost, but I just added not only my Mac's IP address, but then finally '%' as well, and still no luck.

The test server is running RedHat 9. The production server is running RedHat ES 3.

While neither machine accepts Telnet connections, I can telnet port 3306 on the test server and get the version of MySQL returned. Doing the same for the production server just returns a message of connection refused.

Using netstat -a I can see my connection to the test server, but obviously there is no connection on the production machine.

Again, everything else is working normally, it is just nice to use the GUI program to peek into the database and make sure rows are being written as expected, etc., while using the web-based tools that I've created for this project.

Thanks in advance for any advice.

G.--
 
Old 04-06-2004, 10:37 AM   #2
griffey
Member
 
Registered: Jan 2004
Location: East Central Illinois
Distribution: RHEL 4/5/6 and Fedora
Posts: 89

Original Poster
Rep: Reputation: 15
Solution

Hi folks. I'm not intentionally trying to simply return this back to the top of the list, and I apologize for doing so. But I found a solution and thought I'd come back and post it here on the very slight off-chance that someone else runs into the same problem some day (there's nothing worse than finally finding what you think might be a good link on Google only to have it be another dead end...).

Anyway, here's what I did. (With a lot of help from a good friend that knows what he's doing...).

The problem is that my firewall settings are set to "high" on the production box. So I needed to poke a small hole in the firewall to let me connect. I did that with the iptables configuration file.

You'll need to open a terminal and log in as root (using su -l).

First I made a backup copy of that file.

cd /etc/sysconfig
cp iptables iptables.bak

Then I used vi editor (you can use your editor of choice, of course) and modified that file.

After the last "ACCEPT" line and before the "REJECT" line I added the following line:

-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp -s 192.168.123.123 --dport 3306 -j ACCEPT

All on one line. And of course, substitute your own IP address for 192.168.123.123 (by "own IP" I mean the IP address of the OS X machine that you are using to connect to the server, NOT the IP address of the server itself--what this is doing is allowing the OS X box with the IP address specified to connect to the server through the closed-to-everyone-else port 3306, which is what MySQL uses).

After saving that file you have to restart iptables. Do this by typing:

service iptables restart

You should get an [OK] message that they shut down and then two or three more [OK] messages as they start back up. If you get an error, it most likely means that you typed that line wrong (or that I typed it wrong and you copied it correctly...). Either way, your firewall is down so you'll need to go move that file that we just edited, and copy the backup file again.

cp iptables.bak iptables

Now do service iptables restart and it should start up with the old (working) settings.

Check the file that you edited for a typo, and if it still doesn't work maybe the typo is mine (I checked it several times so I think it should be okay...).

Good luck. I hope this helps someone out in the future. Actually, I hope noone else has this problem, but if they do--oh, well, nevermind.

G.--
 
  


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
problem in connecting mysql ansishere General 1 11-14-2005 04:42 AM
problem in connecting to mysql seshank Linux - Software 1 07-22-2005 08:16 PM
mysql connecting problem Zerodark Linux - Software 2 08-17-2003 10:43 PM
connecting to mysql dkc_ace Linux - General 2 03-22-2003 07:18 PM
Mysql is not connecting from servlet.But connecting from java, help pls Harish_f Linux - General 0 05-08-2002 03:21 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 06:33 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