LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 02-21-2003, 01:24 PM   #1
dsiguy
Member
 
Registered: Nov 2002
Posts: 70

Rep: Reputation: 15
mysql_pconnect problem


I am running mysql with apache and php.

The computer that is running apache is not the same as the mysql server.

lets say apache is 192.168.0.1
and
mysql is 192.168.0.2

Normally I use the below info to connect to Mysql when it is on the same machine however in my case it is not on my same machine.

$result = @mysql_pconnect("localhost", "book_bc", "admin");

I have tried to to the following with no luck.

$result = @mysql_pconnect("192.168.0.2", "book_bc", "admin");

Can I do this or is there another way to do this by ip or domain name.
 
Old 02-21-2003, 01:26 PM   #2
nxny
Member
 
Registered: May 2002
Location: AK - The last frontier.
Distribution: Red Hat 8.0, Slackware 8.1, Knoppix 3.7, Lunar 1.3, Sorcerer
Posts: 771

Rep: Reputation: 30
Is the mysql port open on the machine that runs the DB?
 
Old 02-21-2003, 01:29 PM   #3
dsiguy
Member
 
Registered: Nov 2002
Posts: 70

Original Poster
Rep: Reputation: 15
you know that is a good questions I am not sure!

How can i tell.

I run RH8.0.
 
Old 02-21-2003, 01:40 PM   #4
nxny
Member
 
Registered: May 2002
Location: AK - The last frontier.
Distribution: Red Hat 8.0, Slackware 8.1, Knoppix 3.7, Lunar 1.3, Sorcerer
Posts: 771

Rep: Reputation: 30
Code:
telnet 192.168.0.2 3306
should generate output similar to

Trying 192.168.0.2..
Connected to 192.168.0.2
Escape character is '^]'.
(
3.23.54et9_R]\8,

instead of saying connection refused.

You may also want to try using the mysql client on your apache box to see if it can get to the mysql box

Code:
mysql --host 192.168.0.2
and see what it says.
 
Old 02-21-2003, 02:04 PM   #5
dsiguy
Member
 
Registered: Nov 2002
Posts: 70

Original Poster
Rep: Reputation: 15
Well I tried to telnet with the port however I get connection refused because the machine activly refused it.

So i guess that is a no that the mysql port is not accepting calls

I will try to open that port any suggestions

Thanks for all your help.
 
Old 02-21-2003, 02:14 PM   #6
dsiguy
Member
 
Registered: Nov 2002
Posts: 70

Original Poster
Rep: Reputation: 15
I tried to open the port with the following

iptables -A INPUT --destination-port 3306 -i ppp0 -j ACCEPT

However it does not work it comes back unknown arg --3306

Am i doing this right, well I know I am not.

Any help would be great!
 
Old 02-21-2003, 02:30 PM   #7
nxny
Member
 
Registered: May 2002
Location: AK - The last frontier.
Distribution: Red Hat 8.0, Slackware 8.1, Knoppix 3.7, Lunar 1.3, Sorcerer
Posts: 771

Rep: Reputation: 30
Is the MySQL box running RH 8.0 too? In that case you may need to login as root to this box and reconfigure the iptables rules so as to allow incoming connections to TCP port 3306 ( mysql default port ).

Something along the lines of
Code:
iptables -I INPUT -p tcp --source 192.168.0/24 --destination-port mysql -j  ACCEPT
should suffice, but only if RH is not declaring a custom chain and doing complex things with it. You may post your current rules after listing them out using
iptables -L


I suggest reading
http://www.netfilter.org/documentati...ing-HOWTO.html
http://www.justlinux.com/nhf/Securit...es_Basics.html
http://www.netfilter.org/documentati...-tutorial.html

in that order if you want to delve into the underpinnings of packet filtering in general and iptables in particular.

Last edited by nxny; 02-21-2003 at 02:34 PM.
 
Old 02-21-2003, 02:39 PM   #8
nxny
Member
 
Registered: May 2002
Location: AK - The last frontier.
Distribution: Red Hat 8.0, Slackware 8.1, Knoppix 3.7, Lunar 1.3, Sorcerer
Posts: 771

Rep: Reputation: 30
Quote:
Originally posted by dsiguy
I tried to open the port with the following

iptables -A INPUT --destination-port 3306 -i ppp0 -j ACCEPT

However it does not work it comes back unknown arg --3306

Am i doing this right, well I know I am not.

Any help would be great!
I would take the -i ppp0 away since it stands for 'over interface ppp0'. But that doesnt guarantee it. Try posting the complete listing of rules using iptables -L
 
Old 02-21-2003, 03:01 PM   #9
dsiguy
Member
 
Registered: Nov 2002
Posts: 70

Original Poster
Rep: Reputation: 15
I did this

iptables -I INPUT -p tcp --source 192.168.0/24 --destination-port mysql -j ACCEPT

but i try to connect via telnet

telnet (ip address) 3306

and I get activly refused

i even restarted the ipchains

iptables -L shows the following

Chain INPUT (policy ACCEPT)
target prot opt source destination
RH-Lokkit-0-50-INPUT all -- anywhere anywhere

Chain FORWARD (policy ACCEPT)
target prot opt source destination

Chain OUTPUT (policy ACCEPT)
target prot opt source destination

Chain RH-Lokkit-0-50-INPUT (1 references)
target prot opt source destination
ACCEPT tcp -- anywhere anywhere tcp dpt:smtp flags:S
YN,RST,ACK/SYN
ACCEPT tcp -- anywhere anywhere tcp dpt:http flags:S
YN,RST,ACK/SYN
ACCEPT tcp -- anywhere anywhere tcp dpt:ftp flags:SY
N,RST,ACK/SYN
ACCEPT tcp -- anywhere anywhere tcp dpt:ssh flags:SY
N,RST,ACK/SYN
ACCEPT tcp -- anywhere anywhere tcp dpt:telnet flags
:SYN,RST,ACK/SYN
ACCEPT udp -- anywhere anywhere udp spts:bootps:boot
pc dpts:bootps:bootpc
ACCEPT udp -- anywhere anywhere udp spts:bootps:boot
pc dpts:bootps:bootpc
ACCEPT all -- anywhere anywhere
ACCEPT all -- anywhere anywhere
REJECT tcp -- anywhere anywhere tcp dpts:0:1023 flag
s:SYN,RST,ACK/SYN reject-with icmp-port-unreachable
REJECT tcp -- anywhere anywhere tcp dpt:nfs flags:SY
N,RST,ACK/SYN reject-with icmp-port-unreachable
REJECT udp -- anywhere anywhere udp dpts:0:1023 reje
ct-with icmp-port-unreachable
REJECT udp -- anywhere anywhere udp dpt:nfs reject-w
ith icmp-port-unreachable
REJECT tcp -- anywhere anywhere tcp dpts:x11:6009 fl
ags:SYN,RST,ACK/SYN reject-with icmp-port-unreachable
REJECT tcp -- anywhere anywhere tcp dpt:xfs flags:SY
N,RST,ACK/SYN reject-with icmp-port-unreachable
 
Old 02-21-2003, 04:10 PM   #10
nxny
Member
 
Registered: May 2002
Location: AK - The last frontier.
Distribution: Red Hat 8.0, Slackware 8.1, Knoppix 3.7, Lunar 1.3, Sorcerer
Posts: 771

Rep: Reputation: 30
Add the following line to /etc/sysconfig/iptables as root under the line that looks like '-A INPUT -j RH-Lokkit-0-50-INPUT'

Code:
-A RH-Lokkit-0-50-INPUT -p tcp -m tcp --dport 3306 --syn -j ACCEPT
now do /sbin/iptables restart. You should be fine if you can telnet it from the other box now.
 
Old 02-24-2003, 12:21 PM   #11
dsiguy
Member
 
Registered: Nov 2002
Posts: 70

Original Poster
Rep: Reputation: 15
problems connecting to mysql from remote

1

Last edited by dsiguy; 02-24-2003 at 12:23 PM.
 
  


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 On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
apache2.0, php4.2.2, & mysql3.23.58 - undefined function: mysql_pconnect() BrianK Programming 2 02-22-2004 06:58 AM
perl problem? apache problem? cgi problem? WorldBuilder Linux - Software 1 09-17-2003 07:45 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

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