在我安装了我的应用程序并正常工作之前,当我在其他设备上使用相同的代码和配置进行新安装时, 我在尝试连接隧道mysql与pdo扩展时出现错误yii 1。PHP PDO MySQL隧道连接双端口
这样的错误消息:
CDbConnection未能打开数据库连接:SQLSTATE [HY000] [2002]无法解析地址 “本地主机:3307:3306”
我只是要与港口3307
连接,但:3306
汽车包括
我已经尝试了一些方法,但一直没有工作
我的主要配置:
'db' => array(
'class' => 'CDbConnection',
'connectionString' => !empty($ini['db']['conn_str'])
? $ini['db']['conn_str'] : 'mysql:host=localhost;dbname=xxx',
'username' => !empty($ini['db']['user'])
? $ini['db']['user'] : 'root',
'password' => isset($ini['db']['password'])
? $ini['db']['password'] : 'xxx',
'tablePrefix' => !empty($ini['db']['prefix'])
? $ini['db']['prefix'] : 'dcl_',
'emulatePrepare' => true,
'charset' => 'utf8',
'schemaCachingDuration' => 86400,
'enableParamLogging' => TRUE,
'enableProfiling' => TRUE,
),
'dbmm' => array(
'class' => 'CDbConnection',
'connectionString' => !empty($ini['dbmm']['conn_str'])
? $ini['dbmm']['conn_str'] : 'mysql:host=localhost;dbname=xxx',
'username' => !empty($ini['dbmm']['user'])
? $ini['dbmm']['user'] : 'root',
'password' => isset($ini['dbmm']['password'])
? $ini['dbmm']['password'] : 'xxx',
'tablePrefix' => !empty($ini['dbmm']['prefix'])
? $ini['dbmm']['prefix'] : 'mm_',
'emulatePrepare' => true,
'charset' => 'utf8',
'schemaCachingDuration' => 86400,
'enableParamLogging' => TRUE,
'enableProfiling' => TRUE,
'attributes' => array(
PDO::MYSQL_ATTR_LOCAL_INFILE => true
),
),
'dbantrian' => array(
'class' => 'CDbConnection',
'connectionString' => !empty($ini['dbantrian']['conn_str'])
? $ini['dbantrian']['conn_str'] : 'mysql:host=localhost;dbname=xxx',
'username' => !empty($ini['dbantrian']['user'])
? $ini['dbantrian']['user'] : 'root',
'password' => isset($ini['dbantrian']['password'])
? $ini['dbantrian']['password'] : 'xxx',
'emulatePrepare' => true,
'charset' => 'utf8',
'schemaCachingDuration' => 86400,
'enableParamLogging' => TRUE,
'enableProfiling' => TRUE,
),
我的.ini文件:
[db]
conn_str = "mysql:host=localhost:3307;dbname=xxx"
user = "root"
password = "xxx"
prefix = "dcl_"
[dbmm]
conn_str = "mysql:host=localhost:3307;dbname=xxx"
user = "root"
password = "xxx"
prefix = "mm_"
[dbantrian]
conn_str = "mysql:host=localhost:3307;dbname=xxx"
user = "root"
password = "xxx"
我使用的工具:
- Ubuntu的16
- Ajenti V
- Nginx的
- PHP 5.6
- PDO和PDO Mysql的
- MariaDB的5.7
,因为我不允许更新的警予
核心文件,我不知道我错过
我不能使用从 PHP PDO initialization fails due to "double port" - Uncaught PDOException: SQLSTATE[HY000] [2002]解决方案感谢之前,我的英语
更新惋惜: 我对旧设备的应用程序有后错误(比如我的新的应用程序)
Setting up php5.6-common (5.6.30-10+deb.sury.org~xenial+2) ...
Setting up php5.6-curl (5.6.30-10+deb.sury.org~xenial+2) ...
Setting up php5.6-sqlite3 (5.6.30-10+deb.sury.org~xenial+2) ...
Setting up php5.6-mbstring (5.6.30-10+deb.sury.org~xenial+2) ...
Setting up php5.6-xml (5.6.30-10+deb.sury.org~xenial+2) ...
Setting up php5.6-gd (5.6.30-10+deb.sury.org~xenial+2) ...
Setting up php5.6-readline (5.6.30-10+deb.sury.org~xenial+2) ...
Setting up php5.6-mcrypt (5.6.30-10+deb.sury.org~xenial+2) ...
Setting up php5.6-json (5.6.30-10+deb.sury.org~xenial+2) ...
Setting up php5.6-mysql (5.6.30-10+deb.sury.org~xenial+2) ...
Setting up php5.6-opcache (5.6.30-10+deb.sury.org~xenial+2) ...
Setting up php5.6-cli (5.6.30-10+deb.sury.org~xenial+2) ...
Setting up php5.6-fpm (5.6.30-10+deb.sury.org~xenial+2) ...
NOTICE: Not enabling PHP 5.6 FPM by default.
NOTICE: To enable PHP 5.6 FPM in Apache2 do:
NOTICE: a2enmod proxy_fcgi setenvif
NOTICE: a2enconf php5.6-fpm
NOTICE: You are seeing this message because you have apache2 package installed.
Setting up php-msgpack (2.0.2+0.5.7-1+deb.sury.org~xenial+2) ...
Setting up php-mysql (1:7.1+52+deb.sury.org~xenial+1) ...
Setting up php-pgsql (1:7.1+52+deb.sury.org~xenial+1) ...
你的PDO连接代码是什么样的?编辑你的问题来增加它,它应该更明显是什么错误。 – tadman
已编辑。我使用Yii1,所以我只是添加连接配置 – Baron
解决。将'host = localhost:3307'改为'host = 127.0.0.1; port = 3307' – Baron