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);
die("Could not connect to MySQL");
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!
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.
Nothing helps like reading the documentation ;)
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.
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!
|All times are GMT -5. The time now is 02:19 PM.|