Home >Backend Development >PHP Tutorial >YIi PDO CDbConnection cannot open the database connection: SQLSTATE[HY000] [2002]

YIi PDO CDbConnection cannot open the database connection: SQLSTATE[HY000] [2002]

WBOY
WBOYOriginal
2016-07-29 09:05:451267browse
升级php 7.0之后,由于php7.0不再支持mysql扩展,只好升级为pdo mysql方式。

装好php7.0新环境之后,遇到CDbConnection 无法开启数据库连线: SQLSTATE[HY000] [2002]错误


解决方式:
   在centos里边,通过
       find / -name mysql.sock  找到  /var/lib/mysql/mysql.sock
   然后找到 php.ini
       修改 
       pdo_mysql.default_socket= /var/lib/mysql/mysql.sock

       mysqli.default_socket =/var/lib/mysql/mysql.sock

解决问题。

The above introduces the YIi PDO CDbConnection cannot open the database connection: SQLSTATE[HY000] [2002], including the relevant content. I hope it will be helpful to friends who are interested in PHP tutorials.

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn