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.
.



Relevant Pages

  • Re: Script stops running during while()
    ... that processes records returned by a MySQL query. ... The HTML page continues trying to load the page but the php has stopped running and eventually I get a timeout. ... I have a new PC and had to re-install php, Apache and MySQL ... The script executed perfectly on my old PC ...
    (comp.lang.php)
  • Re: mySQL accessed remotely
    ... >> I want to know how you can access a remote mySQL database from a php ... > And similarly, if you are going to connect from a php script, you ...
    (alt.php)
  • [Full-Disclosure] [waraxe-2004-SA#031 - Multiple vulnerabilities in e107 version 0.615]
    ... mysql must be version 4.x with enabled UNION ... script - must be kept in secret, when possible, or it ... php error messages, ... Potential attacker can use xss to steal the cookies, ...
    (Full-Disclosure)
  • Re: newbie MySql script question
    ... how do I run this script? ... the best way to administer a mysql ... you have not written any php. ... or just start up mysql and type your SQL statements at the mysql prompt ...
    (comp.lang.php)
  • Script stops running during while()
    ... I have a php script which simply stops midway through a while loop ... that processes records returned by a MySQL query. ... - I have a new PC and had to re-install php, Apache and MySQL ...
    (comp.lang.php)