LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices

Reply
 
Search this Thread
Old 11-27-2009, 01:38 PM   #1
jonaskellens
Member
 
Registered: Jul 2008
Location: Ghent, Belgium
Distribution: Fedora, CentOS
Posts: 617

Rep: Reputation: 33
Connection with remote MySQL-server fails


I'm trying to connect to a remote MySQL-DB from a webserver where I have my website running.

To give the webserver access to the MySQL-server, I define this host in the mysql-database. To be exact the tables host, user and db.
There I mention the webserver with its hostname and its IP-address. In the table user I also mention the usrername and password.

Putting the password in plain or with PASSWORD('') doesn't matter: connection keeps failing.

This is what the browser says :

Warning: mysql_connect() [function.mysql-connect]: Can't connect to MySQL server on 'ipadres' (4) in /var/www/vhosts/domain.be/httpsdocs/connectietest.php on line 5

/var/log/mysqld.log mentions :

Code:
091127 19:12:10 [Warning] Found invalid password for user: 'myuser@hostnamewebserver'; Ignoring user
091127 19:12:10 [Warning] Found invalid password for user: 'myuser@domain.be'; Ignoring user
091127 19:12:10 [Warning] Found invalid password for user: 'myuser@ipwebserver'; Ignoring user
Mysql-CLI gives :

mysql> select * from user where Host="domain.be";
<snip>
| domain.be | myuser | plainpassword | Y | N | N | N
<snip>
1 row in set (0.00 sec)

I have always flushed the privileges after changes.


I just can't connect to my database.

Can someone tell me how a host, username and password should be added to the MySQL-DB for giving this host access to the database-server or the database ?

Using phpMyAdmin for making changes...
 
Old 11-28-2009, 06:26 PM   #2
TB0ne
Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 14,469

Rep: Reputation: 2538Reputation: 2538Reputation: 2538Reputation: 2538Reputation: 2538Reputation: 2538Reputation: 2538Reputation: 2538Reputation: 2538Reputation: 2538Reputation: 2538
Quote:
Originally Posted by jonaskellens View Post
I'm trying to connect to a remote MySQL-DB from a webserver where I have my website running.

To give the webserver access to the MySQL-server, I define this host in the mysql-database. To be exact the tables host, user and db.
There I mention the webserver with its hostname and its IP-address. In the table user I also mention the usrername and password.

Putting the password in plain or with PASSWORD('') doesn't matter: connection keeps failing.

This is what the browser says :

Warning: mysql_connect() [function.mysql-connect]: Can't connect to MySQL server on 'ipadres' (4) in /var/www/vhosts/domain.be/httpsdocs/connectietest.php on line 5

Mysql-CLI gives :

mysql> select * from user where Host="domain.be";
<snip>
| domain.be | myuser | plainpassword | Y | N | N | N
<snip>
1 row in set (0.00 sec)

I have always flushed the privileges after changes.


I just can't connect to my database.

Can someone tell me how a host, username and password should be added to the MySQL-DB for giving this host access to the database-server or the database ?

Using phpMyAdmin for making changes...
Well, I can't help you much with phpMyAdmin...for alot of things, I prefer the command-line, to avoid problems such as this. The more layers, the more confusing things can get.

First, I'd start by eliminating the web/php portion from the equation, and make sure you can just plain connect to the MySQL database from the box. Doing "mysql -h <ip address or host name> -u <user name> -p", should let you put in the users password, and then connect. If it doesn't, you've got connection problems, separate from web/php. Check the iptables/firewall rules on the database server, and make sure they're open. Also, these pages can help you with the user permissions, as far as users/remote systems are concerned:

http://dev.mysql.com/doc/refman/5.1/...ss-denied.html
http://forums.mysql.com/read.php?34,92009
http://www.geekology.co.za/blog/2009...tabase-server/

Once you can connect from the command-line over, and you're still having problems, then you've at least narrowed it down to your PHP page(s).
 
Old 11-30-2009, 03:19 AM   #3
jonaskellens
Member
 
Registered: Jul 2008
Location: Ghent, Belgium
Distribution: Fedora, CentOS
Posts: 617

Original Poster
Rep: Reputation: 33
TB0ne,

even with :

mysql>grant all privileges on mydatabase.* to myuser@"%";

I can not connect to the database.

I have several webservers and only from this 1 webserver I cannot talk to my database-server.

So I narrowed it down to this webserver I guess. Problem is I don't control the webserver, it is controlled by my hosting provider.
So far they have not yet answered to this problem...
 
Old 11-30-2009, 09:34 AM   #4
TB0ne
Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 14,469

Rep: Reputation: 2538Reputation: 2538Reputation: 2538Reputation: 2538Reputation: 2538Reputation: 2538Reputation: 2538Reputation: 2538Reputation: 2538Reputation: 2538Reputation: 2538
Quote:
Originally Posted by jonaskellens View Post
TB0ne,

even with :

mysql>grant all privileges on mydatabase.* to myuser@"%";

I can not connect to the database.

I have several webservers and only from this 1 webserver I cannot talk to my database-server.

So I narrowed it down to this webserver I guess. Problem is I don't control the webserver, it is controlled by my hosting provider.
So far they have not yet answered to this problem...
Did you check the firewall(s) as I suggested? Can you connect to it via the command-line utility?
 
Old 11-30-2009, 02:03 PM   #5
jonaskellens
Member
 
Registered: Jul 2008
Location: Ghent, Belgium
Distribution: Fedora, CentOS
Posts: 617

Original Poster
Rep: Reputation: 33
Quote:
Originally Posted by TB0ne View Post
Did you check the firewall(s) as I suggested? Can you connect to it via the command-line utility?
I do not have ssh-access to the webserver @ my hosting company. Else I would have never had to post this problem.
Your advice is what one should check...
 
Old 11-30-2009, 08:34 PM   #6
TB0ne
Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 14,469

Rep: Reputation: 2538Reputation: 2538Reputation: 2538Reputation: 2538Reputation: 2538Reputation: 2538Reputation: 2538Reputation: 2538Reputation: 2538Reputation: 2538Reputation: 2538
Quote:
Originally Posted by jonaskellens View Post
I do not have ssh-access to the webserver @ my hosting company. Else I would have never had to post this problem.
Your advice is what one should check...
Hard to diagnose, if you can't see the system logs/firewall rules on the web server. Not sure what to suggest...you can check the incoming syslog on your DB server from your web server, and see if you get anything rejected, or use a packet sniffer (wireshark, etc.,), to see if you get ANY packets from that name/address.

Since you've got other web servers working, are they all connecting to one DB server?? If so, focus on the differences in the web servers, and the modules they have loaded. On that note, I'm sure you've made sure the PHP database access modules are loaded, right?
 
  


Reply

Tags
mysql


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
remote connection to MySQL OpusMBE Linux - Software 2 02-28-2007 09:19 AM
MySQL Remote Connection aquatux Linux - Server 5 12-26-2006 07:12 PM
[ JSP/JAVA ] MySQL connection fails White R4bbit Programming 4 04-27-2005 08:31 AM
MySQL connection over TCP/IP fails Rukawa Linux - Software 4 11-29-2003 11:30 PM
Remote Connection to mysql server Graanco Linux - General 1 07-18-2003 11:27 PM


All times are GMT -5. The time now is 01:36 PM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration