跟新完php7.1后访问yii项目出现下图错误 可见数据库链接是已经制指定了端口号9004 但是访问时后续自动加上了3306

BUG:php7.1 访问yii数据库 自动加端口3306 报错

原因:换了方式 

//这种方式只支持5.6版本php
'db' => [
            'class' => 'yii\db\Connection',
             'dsn' => 'mysql:host=192.168.1.4:9004;dbname=qwe',
            'username' => 'root',
            'password' => '*****',
             'charset' => 'utf8',
         ],
//php7  5.6.*通用 的支持方式
 'db' => [
            'class' => 'yii\db\Connection',
           'dsn' => 'mysql:host=192.168.1.4;port=9004;dbname=qwe,
           'username' => 'root',
          'password' => '*****',
          'charset' => 'utf8',
        ],

 修改后项目正常访问

相关文章:

  • 2022-12-23
  • 2021-06-25
  • 2022-12-23
  • 2022-12-23
  • 2021-05-18
  • 2021-07-18
  • 2021-10-22
  • 2022-01-04
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-12-14
  • 2021-08-27
  • 2021-05-22
  • 2021-06-13
  • 2022-12-23
相关资源
相似解决方案