
11-19-2010, 01:33 PM
|
|
Newbie
|
|
Join Date: Nov 2010
Location: India
Posts: 13
|
|
apache not able to connect to mysql using ip on same server
apache not able to connect to mysql using ip on same server
I'm also having a issue with mysql database server and apache web server running php.
I'm using apache php to connect to mysql using IP as db host on the same server,
but when I use localhost as db host - it works.
|

11-19-2010, 01:50 PM
|
|
COLOCATE LIKE A BOSS
|
|
Join Date: Feb 2004
Location: Atlanta, GA
Posts: 5,526
|
|
that would be because your mysql user is probably only authorized to connect from local host.
You should always be using LO and not an IP bound to an Ethernet interface for scripts on the server.
__________________
Ryan DiRocco
██ COLO@ Colocation. Perfected.
██ Atlanta - Chicago - Dallas - Phoenix - Clifton - Los Angeles
Total Server Solutions - Servers - US Based Support - Server Management
|

11-19-2010, 01:57 PM
|
|
Newbie
|
|
Join Date: Nov 2010
Location: India
Posts: 13
|
|
I've dedicated server, can you tell me - what files/settings needs to be changed?
I've already stopped the firewall on the server.
|

11-19-2010, 02:02 PM
|
|
Web Hosting Master
|
|
Join Date: Mar 2009
Posts: 596
|
|
Quote:
Originally Posted by jsxtech
I've dedicated server, can you tell me - what files/settings needs to be changed?
I've already stopped the firewall on the server.
|
First, turn the firewall back on.
__________________
[GB ≠ GiB] [MB ≠ MiB] [kB ≠ kiB] [1000 ≠ 1024] [Giga ≠ gram] [Mega ≠ milli] [Kelvin ≠ kilo] [Byte ≠ bit]
There is no millibit. There is no gram-bit. There is no Kelvin-Byte.
|

11-19-2010, 02:15 PM
|
|
WHT Addict
|
|
Join Date: Sep 2010
Location: Dallas, TX
Posts: 162
|
|
Try "telnet <ip> 3306" If you're getting a connection refused, you'll need to modify your my.cnf and modify the bind-address statement so mysql will answer on the IP address.
As Ryan said though, using localhost only is best if you're not going to connect to the mysql server from a remote machine.
|

11-19-2010, 02:16 PM
|
|
Newbie
|
|
Join Date: Nov 2010
Location: India
Posts: 13
|
|
ya, did already - firewall is up again.
|

11-19-2010, 02:21 PM
|
|
Newbie
|
|
Join Date: Nov 2010
Location: India
Posts: 13
|
|
I want to access this mysql database server from other server as well.
But the first thing is - apache not able to connect to mysql using ip on same server.
I've checked my /etc/my.cnf, there is no line for bind-address.
|

11-19-2010, 02:23 PM
|
|
The Guru!
|
|
Join Date: Nov 2007
Location: Chennai, India
Posts: 2,300
|
|
What script you are using? Try using localhost instead of server IP
|

11-19-2010, 02:24 PM
|
|
WHT Addict
|
|
Join Date: Sep 2010
Location: Dallas, TX
Posts: 162
|
|
Is there a skip-networking statement in there? If so, comment it out.
What version of mysql are you running?
|

11-19-2010, 02:39 PM
|
|
Design and Hosting Solutions
|
|
Join Date: May 2005
Location: New York
Posts: 736
|
|
like mentioned above there are 2 steps in the process, determining whether MySQL is listening on anything other than localhost (lo) first - then ensuring that database users that are added/configured are done so for the correct host ip address.
The listening/networking parts can be determined/verified by netstat -ln and using telnet to port 3306 from the various remote hosts that will be connecting. Make sure that you allow only explicit ips access to destination port 3306 via iptables on your database server
__________________
█ Perigee Global Corporation
█ Design, Development and Hosting Solutions
█ Dedicated Servers, CDN, Hosted E-Mail, Web Hosting, VPS & Cloud Servers
█ 1.212.400-7632 www.perigeeglobal.com
|

11-19-2010, 03:25 PM
|
|
Newbie
|
|
Join Date: Nov 2010
Location: India
Posts: 13
|
|
There is no - skip-networking statement in /etc/my.cnf file.
One more thing - firewall is CSF not iptables.
Can anyone help with CSF also?
Last edited by jsxtech; 11-19-2010 at 03:27 PM.
Reason: adding more details
|

11-19-2010, 04:22 PM
|
|
Web Hosting Master
|
|
Join Date: Mar 2009
Posts: 596
|
|
Quote:
Originally Posted by jsxtech
There is no - skip-networking statement in /etc/my.cnf file.
One more thing - firewall is CSF not iptables.
Can anyone help with CSF also?
|
CSF is not a firewall. CSF is a configuration utility/script that makes iptables management somewhat easier. Rather than putting port 3306 in the allow lists in csf.conf, just add the IPs of any other server you want to allow to connect into csf.allow.
__________________
[GB ≠ GiB] [MB ≠ MiB] [kB ≠ kiB] [1000 ≠ 1024] [Giga ≠ gram] [Mega ≠ milli] [Kelvin ≠ kilo] [Byte ≠ bit]
There is no millibit. There is no gram-bit. There is no Kelvin-Byte.
Last edited by petteyg359; 11-19-2010 at 04:25 PM.
|

11-19-2010, 11:11 PM
|
|
Newbie
|
|
Join Date: Nov 2010
Location: India
Posts: 13
|
|
I've already added the IP in csf.allow, but still no luck
|

11-19-2010, 11:19 PM
|
|
Web Hosting Master
|
|
Join Date: Mar 2009
Posts: 596
|
|
Did you restart CSF? iptables rules aren't reloaded until you tell it to do so.
Also, as jNive said, have you added a database user with that IP allowed for login?
__________________
[GB ≠ GiB] [MB ≠ MiB] [kB ≠ kiB] [1000 ≠ 1024] [Giga ≠ gram] [Mega ≠ milli] [Kelvin ≠ kilo] [Byte ≠ bit]
There is no millibit. There is no gram-bit. There is no Kelvin-Byte.
|

11-19-2010, 11:32 PM
|
|
Design and Hosting Solutions
|
|
Join Date: May 2005
Location: New York
Posts: 736
|
|
mysql> CREATE USER 'someusername'@'ip.add.re.ss' WITH PASSWORD 'somereallycleverpassword';
mysql> GRANT ALL on adatabasename.* TO 'someusername'@'ip.add.re.ss';
mysql> flush privileges;
quick set of mysql commands for adding users & granting all permissions
__________________
█ Perigee Global Corporation
█ Design, Development and Hosting Solutions
█ Dedicated Servers, CDN, Hosted E-Mail, Web Hosting, VPS & Cloud Servers
█ 1.212.400-7632 www.perigeeglobal.com
|
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Linear Mode
|
| Postbit Selector |
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
|
|
| Login: |
|
|
| Advertisement: |
|
|
| Web Hosting News: |
|
|
|