LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices


Reply
  Search this Thread
Old 09-16-2004, 10:39 PM   #1
inspleak
LQ Newbie
 
Registered: Jul 2003
Location: Michigan
Posts: 21

Rep: Reputation: 15
MySQL and remote database


Hey guys, I've spent two days on this and I'm out of ideas.

Here is my situation, I am trying to connect to a database from a PHP page that is not on the same box as the database.

so I do this:
$link=mysql_connect($dbHost, $user, $password);
if(! $link)
die("Could not connect to MySQL");

mysql_select_DB($database, $link)
or die ("Cound not open $database, $link: ".mysql_error());

then I get some records from the database and print them out.

All of this works fine if the PHP page is on the same box as the database and I have $dbHost set to be "localhost"

However when I move the php page to a different box and change the $dbHost var to be the ip of the box with the DB on it I get the following error:
Warning: Host 'myIPHere' is not allowed to connect to this MySQL server.

So its talking to the mySQL server and it finds the database. Somewhere I need to give it access. I'm assuming that I'm missing something in the my.cnf file, but I can't for the life of me figure out what it is.

Any ideas? Pppllleeeaassseee?

Thanks so much for the help!

-Jake
 
Old 09-16-2004, 11:37 PM   #2
skecs
LQ Newbie
 
Registered: Sep 2004
Location: Bathurst Australia
Distribution: Suse 9.2 but have used Suse 9.1 Red Hat 5.2 - 9, Linux Defender Live!, Knoppix, Morphix
Posts: 12

Rep: Reputation: 0
URL Required

Hi,

You need to change "localhost" to the URL of the database server - possibly "mysql.domainname.com.au" - and then follow with the username & password on that server.
 
Old 09-16-2004, 11:39 PM   #3
CroMagnon
Member
 
Registered: Sep 2004
Location: New Zealand
Distribution: Debian
Posts: 900

Rep: Reputation: 33
Nothing helps like reading the documentation
(From http://dev.mysql.com/doc/mysql/en/Access_denied.html)
If the following error occurs when you try to connect from a host other than the one on which the MySQL server is running, it means that there is no row in the user table with a Host value that matches the client host:

Host ... is not allowed to connect to this MySQL server

You can fix this by setting up an account for the combination of client hostname and username that you are using when trying to connect. If you don't know the IP number or hostname of the machine from which you are connecting, you should put an entry with '%' as the Host column value in the user table and restart mysqld with the --log option on the server machine. After trying to connect from the client machine, the information in the MySQL log will indicate how you really did connect. (Then change the '%' in the user table entry to the actual hostname that shows up in the log. Otherwise, you'll have a system that is insecure because it allows connections from any host for the given username.) On Linux, another reason that this error might occur is that you are using a binary MySQL version that is compiled with a different version of the glibc library than the one you are using. In this case, you should either upgrade your operating system or glibc, or download a source distribution of MySQL version and compile it yourself. A source RPM is normally trivial to compile and install, so this isn't a big problem.
 
Old 09-17-2004, 01:00 AM   #4
inspleak
LQ Newbie
 
Registered: Jul 2003
Location: Michigan
Posts: 21

Original Poster
Rep: Reputation: 15
CroMagnon Sir... you are the man!

Thank you very much for pointing me to that! Its all good now..

I still don't know how to setup the Username/Hostname pairs from within mysql, but webmin got me through it.

thanks again to everyone!

-Jake
 
  


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
connecting to MYSQL remote database opsraja Linux - Software 1 02-18-2005 05:52 AM
Writing an app that uses a mysql database without installing mysql server? QtCoder Programming 4 08-09-2004 02:43 PM
MYSQL help - mysql database missing eloviyandhi Linux - Software 1 03-20-2004 09:20 PM
Using Tora to connect to remote database devinWhalen Linux - Software 0 02-18-2004 03:15 PM
Connecting Mysql Database on remote server akamol Programming 4 10-16-2003 11:46 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Networking

All times are GMT -5. The time now is 11:54 AM.

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