Home  >  Article  >  Database  >  PHP 连接 unix_socket MySQL

PHP 连接 unix_socket MySQL

WBOY
WBOYOriginal
2016-06-07 16:41:341476browse

当MySQL使用Unix Socket启动时,直接使用localhost会发生了一个数据库错误,发生无法连接数据库错误。 Warning: mysql_connect() [function.mysql-connect]: [2002] 这时应当修改hostname,例如在CI 配置数据库 (database.php) 从: $db['default']['hostnam

当MySQL使用Unix Socket启动时,直接使用localhost会发生了一个数据库错误,发生无法连接数据库错误。

Warning: mysql_connect() [function.mysql-connect]: [2002]

这时应当修改hostname,例如在CI 配置数据库 (database.php) 从:

 $db['default']['hostname']?=?'localhost';? 

到:

$db['default']['hostname']?=?'localhost:/Applications/mamp/mysql/tmp/mysql.sock';

php connect unix socket mysql

(...)
Read the rest of PHP 连接 unix_socket MySQL (47 words)


© Li Xi for LixiPHP, 2014. | Permalink | No comment | Add to del.icio.us
Post tags: CI, drupal, MySQL, unix_socket

Feed enhanced by Better Feed from Ozh

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