Re: mySQL accessed remotely



On Wed, 27 Apr 2005 18:32:12 -0700, Kenneth wrote:

> I want to know how you can access a remote mySQL database from a php
> script.
>
> Also how can I connect to a remote mysql database from mysql administrator?

Hi,

don't know if you found the proper answer from the other posters, who
seemed to just send you links.

All you need to do to access remotely, assuming you have the permission to
do so and assuming you can indeed make a connection to the remote server,
is to specify the correct host variable.

If you are trying to connect to mysql as user "dbuser" using a password on
your local computer (from a terminal window), you of course can use

> mysql -u dbuser -p

but if the database is located on a remote server, say at www.website.com,
then the command becomes

> mysql -h www.website.com -u dbuser -p

This is the same set of arguments you use for any mysql administrative
program called from the command line, for example mysql dump:

> mysqldump -h www.website.com -u dbuser -p --all-databases > dump.sql

And similarly, if you are going to connect from a php script, you
basically do the same trick: you specify the HOST in the php function call:

> $mysql = mysql_connect($host,$user,$password);

with $host set in this case to 'www.website.com'

Hope that helps.
.