Connecting to mysql from another host

Connecting to mysql from another host

am 03.08.2007 08:59:06 von joefazee

------=_Part_19500_11961383.1186124346867
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit


I want to connect to a database hosted on another server like from
www.sample.com i want to connect to www.example2.com.what did i need to do?

Thanks.
--
View this message in context: http://www.nabble.com/Connecting-to-mysql-from-another-host- tf4210929.html#a11978401
Sent from the Php - Database mailing list archive at Nabble.com.

------=_Part_19500_11961383.1186124346867--

Re: Connecting to mysql from another host

am 03.08.2007 10:26:48 von Goltsios Theodore

Well you it depends on what method you use to access mysql. If for
instance if you use PDO you could do something like that to connect and
query:

$dbhost = 'remote_hostname';
$dbuser = 'mysql_username';
$dbpass = 'mypass';
$db = 'database_to_use';

$db_handler = new PDO('mysql:host='.$dbhost.';dbname='.$db, $dbuser,
$dbpass);

$query = "SELECT id, fname, lname FROM users WHERE id>'1'";
$st_handler = $db_handler->prepare($query);
$st_handler->execute();

?>

Have in mind that you must have installed the PDO mysql modules using
pear for this method to work. There are other methods like this one:
http://www.php-mysql-tutorial.com/connect-to-mysql-using-php .php

Have fun,

Theodoros Goltsios
Kinetix Tele.com Support Center
email: tgol@kinetix.gr, support@kinetix.gr
Tel. & Fax: +30 2310556134
WWW: http://www.kinetix.gr/



joefazee wrote:
> I want to connect to a database hosted on another server like from
> www.sample.com i want to connect to www.example2.com.what did i need to do?
>
> Thanks.
>

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Re: Connecting to mysql from another host

am 03.08.2007 12:09:03 von robleyd

joefazee wrote:

>
> I want to connect to a database hosted on another server like from
> www.sample.com i want to connect to www.example2.com.what did i need to
> do?
>
> Thanks.

First up you need to ensure that www.example2.com a) allows remote
connections and b) has privileges for user@www.example.com



Cheers
--
David Robley

Why doesn't the Bat Computer ever crash?
Today is Setting Orange, the 69th day of Confusion in the YOLD 3173.

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php