Re: mySQL accessed remotely



coolsti wrote:

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

I actually provided an answer about how to do it, to the same post which
was posted separately to comp.lang.php - this is why people should
crosspost and not multipost. If he'd crossposted then my answer would
have appeared in this group as well.

--
Chris Hope | www.electrictoolbox.com | www.linuxcdmall.com
.



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)
  • [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)
  • 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)
  • Re: [PHP] Code works alone but not with other code.
    ... place it alone in a php script it works just fine, ... the script seem like it's just skipping this chunk of code, ... The code does use nested MySQL queries, it worked before but I thought ...
    (php.general)
  • Re: Have you heard about a MySQL connection leak?
    ... We're using PHP 5 and MySQL 5. ... Can't connect to MySQL: 'Too many connections' ... we connect to the db (script included on every page) ... ...
    (comp.lang.php)