|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2005-08-10 18:11 UTC] pash_ka at fonbet dot info
Description:
------------
I can't connect with my MySQL server running on localhost using non-standart port.
I've tried dsn
mysql:host=localhost;port=6733;dbname=www
(resulted with "Can't connect to MySQL server on 'localhost' (10061)" error)
mysql:host=localhost:6733;dbname=www
(resulted with "Unknown MySQL server host 'localhost:6733' (11001)" error)
I've also tried to use
ini_set('mysql.default_port', 6733);
and set in php.ini
I've tried it with PHP 5.1 beta3 and with php_pdo_mysql.dll from "php5-win32-latest.zip" (09.08.2005).
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Thu Oct 30 12:00:01 2025 UTC |
I've tried it with latest (Aug 30 2005 08:37:40) build, and using 127.0.0.1 instead of localhost works. I'm using this test script: ------------------------------------------- <?php if(!isset($argv)){ header('Content-type: text/plain'); header("Content-Disposition: inline; filename=dbotest.txt"); } $cfg['host'] = 'localhost'; //$cfg['host'] = '127.0.0.1'; $cfg['port'] = 6733; $cfg['database'] = 'www-new'; $cfg['username'] = 'pasha'; $cfg['password'] = '****'; connect_mysql($cfg); echo "\n"; connect_pdo_mysql($cfg); function connect_mysql($cfg){ $dsn = $cfg['host'].':'.$cfg['port']; echo "Connecting to MYSQL (DSN = {$dsn}).\n"; @$res = mysql_connect($dsn, $cfg['username'], $cfg['password']); echo 'Result: '.($res?'OK':mysql_error())."\n"; return $res; } function connect_pdo_mysql($cfg){ $dsn = "mysql:host={$cfg['host']};port={$cfg['port']};dbname={$cfg['database']}"; echo "Connecting to PDO_MYSQL (DSN = {$dsn}).\n"; try{ $res = new PDO($dsn, $cfg['username'], $cfg['password']); echo "Result: OK\n"; return $res; }catch(PDOException $ex){ echo 'Result: '.$ex->getMessage()."\n"; return false; } } ?> ------------------------------------------- And this is the result when using localhost: ------------------------------------------ Connecting to MYSQL (DSN = localhost:6733). Result: OK Connecting to PDO_MYSQL (DSN = mysql:host=localhost;port=6733;dbname=www-new). Result: SQLSTATE[HY000] [2003] Can't connect to MySQL server on 'localhost' (10061) ------------------------------------------