FAQ
Hi,
has anyone noticed PDO/MySQL will always try to connect locally
regardless of what I put in the host=... DSN part?

The statement:
new PDO('mysql:host=php3.de', '****', '*******');

will only throw a PDOException:

Fatal error: Uncaught exception 'PDOException' with message
'SQLSTATE[HY000] [2002] Can't connect to local MySQL server through
socket '/tmp/mysql.sock' (2)' in /usr/home/thekid/pdo.php:2

This here fixes it:

Index: ext/pdo_mysql/mysql_driver.c
===================================================================
RCS file: /repository/php-src/ext/pdo_mysql/mysql_driver.c,v
retrieving revision 1.36
diff -u -r1.36 mysql_driver.c
--- ext/pdo_mysql/mysql_driver.c 13 Feb 2005 17:16:24 -0000
1.36
+++ ext/pdo_mysql/mysql_driver.c 18 Feb 2005 10:00:31 -0000
@@ -327,6 +327,7 @@
if (vars[2].optval && !strcmp("localhost", vars[2].optval)) {
unix_socket = vars[4].optval;
} else {
+ host = vars[2].optval;
port = atoi(vars[3].optval);
}
dbname = vars[1].optval;

--
Timm
If it ain't broken, it doesn't have enough features yet

Search Discussions

  • Wez Furlong at Feb 18, 2005 at 3:11 pm
    Thanks; committed.

    --Wez.

    On Fri, 18 Feb 2005 11:16:34 +0100, Timm Friebe wrote:
    Hi,
    has anyone noticed PDO/MySQL will always try to connect locally
    regardless of what I put in the host=... DSN part?

    The statement:
    new PDO('mysql:host=php3.de', '****', '*******');

    will only throw a PDOException:

    Fatal error: Uncaught exception 'PDOException' with message
    'SQLSTATE[HY000] [2002] Can't connect to local MySQL server through
    socket '/tmp/mysql.sock' (2)' in /usr/home/thekid/pdo.php:2

    This here fixes it:

    Index: ext/pdo_mysql/mysql_driver.c
    ===================================================================
    RCS file: /repository/php-src/ext/pdo_mysql/mysql_driver.c,v
    retrieving revision 1.36
    diff -u -r1.36 mysql_driver.c
    --- ext/pdo_mysql/mysql_driver.c 13 Feb 2005 17:16:24 -0000
    1.36
    +++ ext/pdo_mysql/mysql_driver.c 18 Feb 2005 10:00:31 -0000
    @@ -327,6 +327,7 @@
    if (vars[2].optval && !strcmp("localhost", vars[2].optval)) {
    unix_socket = vars[4].optval;
    } else {
    + host = vars[2].optval;
    port = atoi(vars[3].optval);
    }
    dbname = vars[1].optval;

    --
    Timm
    If it ain't broken, it doesn't have enough features yet

    --
    PHP Internals - PHP Runtime Development Mailing List
    To unsubscribe, visit: http://www.php.net/unsub.php

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupphp-internals @
categoriesphp
postedFeb 18, '05 at 12:49p
activeFeb 18, '05 at 3:11p
posts2
users2
websitephp.net

2 users in discussion

Wez Furlong: 1 post Timm Friebe: 1 post

People

Translate

site design / logo © 2019 Grokbase