hosted by liquidweb


Go Back   Web Hosting Talk : Web Hosting Main Forums : Hosting Security and Technology : apache not able to connect to mysql using ip on same server
Reply

Hosting Security and Technology Configuring and optimizing web hosting servers and operating systems, developing administration scripts, building servers, protecting against hackers, and general security (SSL certificates, etc.)
Forum Jump

apache not able to connect to mysql using ip on same server

Reply Post New Thread In Hosting Security and Technology Subscription
 
Send news tip View All Posts Thread Tools Search this Thread Display Modes
  #1  
Old 11-19-2010, 01:33 PM
jsxtech jsxtech is offline
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.

Reply With Quote


Sponsored Links
  #2  
Old 11-19-2010, 01:50 PM
RyanD RyanD is offline
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

Reply With Quote
  #3  
Old 11-19-2010, 01:57 PM
jsxtech jsxtech is offline
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.

Reply With Quote
Sponsored Links
  #4  
Old 11-19-2010, 02:02 PM
petteyg359 petteyg359 is offline
Web Hosting Master
 
Join Date: Mar 2009
Posts: 596
Quote:
Originally Posted by jsxtech View Post
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.

Reply With Quote
  #5  
Old 11-19-2010, 02:15 PM
ColoUnlimited ColoUnlimited is offline
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.

__________________
ColoUnlimited
Dallas colocation bundled with 100 megabits of unmetered bandwidth. Month-to-month service terms available.
http://www.colounlimited.com
phone: 877-298-5237 email: sales@colounlimited.com

Reply With Quote
  #6  
Old 11-19-2010, 02:16 PM
jsxtech jsxtech is offline
Newbie
 
Join Date: Nov 2010
Location: India
Posts: 13
ya, did already - firewall is up again.

Reply With Quote
  #7  
Old 11-19-2010, 02:21 PM
jsxtech jsxtech is offline
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.

Reply With Quote
  #8  
Old 11-19-2010, 02:23 PM
chennaihomie chennaihomie is offline
The Guru!
 
Join Date: Nov 2007
Location: Chennai, India
Posts: 2,300
What script you are using? Try using localhost instead of server IP

Reply With Quote
  #9  
Old 11-19-2010, 02:24 PM
ColoUnlimited ColoUnlimited is offline
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?

__________________
ColoUnlimited
Dallas colocation bundled with 100 megabits of unmetered bandwidth. Month-to-month service terms available.
http://www.colounlimited.com
phone: 877-298-5237 email: sales@colounlimited.com

Reply With Quote
  #10  
Old 11-19-2010, 02:39 PM
jNive jNive is offline
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

Reply With Quote
  #11  
Old 11-19-2010, 03:25 PM
jsxtech jsxtech is offline
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
Reply With Quote
  #12  
Old 11-19-2010, 04:22 PM
petteyg359 petteyg359 is offline
Web Hosting Master
 
Join Date: Mar 2009
Posts: 596
Quote:
Originally Posted by jsxtech View Post
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.
Reply With Quote
  #13  
Old 11-19-2010, 11:11 PM
jsxtech jsxtech is offline
Newbie
 
Join Date: Nov 2010
Location: India
Posts: 13
I've already added the IP in csf.allow, but still no luck

Reply With Quote
  #14  
Old 11-19-2010, 11:19 PM
petteyg359 petteyg359 is offline
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.

Reply With Quote
  #15  
Old 11-19-2010, 11:32 PM
jNive jNive is offline
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

Reply With Quote
Reply

Similar Threads
Thread Thread Starter Forum Replies Last Post
Can't connect to local MySQL server through socket '/var/tmp/mysql.sock' (11) motyl Hosting Security and Technology 29 03-09-2007 12:26 PM
Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2) manisha_khtri Hosting Security and Technology 2 06-05-2006 10:05 AM
how to connect apache and mysql server together via internal IP? beniceman Hosting Security and Technology 1 09-09-2005 02:56 AM
Can't connect to local MySQL server through socket '/tmp/mysql.sock' stickygoblin Hosting Security and Technology 13 06-18-2004 11:10 AM
ERROR 2002: Can't connect to local MySQL server through socket '/var/lib/mysql/mysql. atul Hosting Security and Technology 5 05-11-2004 12:24 AM

Related posts from TheWhir.com
Title Type Date Posted
Researchers Urge System Admins to Check for New Apache Web Server Backdoor Malware Web Hosting News 2013-05-01 11:35:53
nginx Sees Largest Market Share Growth in Netcraft March Server Survey Web Hosting News 2012-03-05 14:05:29
Apache Web Server Adds Cloud Capabilities with First Major Update in 5 Years Web Hosting News 2012-02-21 16:05:02
Oracle is the Latest Vendor to Apply Patch for Apache Killer Flaw Web Hosting News 2011-09-19 14:43:58
Patch Released for Apache Software DDoS Vulnerability Web Hosting News 2011-08-26 15:03:10


Tags
apache, database, dedicated, internet, mysql, php, programming, server

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes
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

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

Forum Jump
Login:
Log in with your username and password
Username:
Password:



Forgot Password?
Advertisement:
Web Hosting News:



 

X

Welcome to WebHostingTalk.com

Create your username to jump into the discussion!

WebHostingTalk.com is the largest, most influentual web hosting community on the Internet. Join us by filling in the form below.


(4 digit year)

Already a member?