chr*_*san 4 mysql zend-framework zend-db
在OSX上,当我尝试使用以下内容时:
resources.db.adapter = "pdo_mysql"
resources.db.params.dbname = "myDb"
resources.db.params.host = "localhost"
resources.db.params.username = "root"
resources.db.params.password = ""
Run Code Online (Sandbox Code Playgroud)
我收到以下错误
Warning: PDO::__construct(): [2002] No such file or directory (trying to connect via unix:///var/mysql/mysql.sock) in /Library/WebServer/sites/testweb/library/Zend/Db/Adapter/Pdo/Abstract.php on line 129
Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[HY000] [2002] No such file or directory' in /Library/WebServer/sites/testweb/library/Zend/Db/Adapter/Pdo/Abstract.php:129
Stack trace:
#0 /Library/WebServer/sites/testweb/library/Zend/Db/Adapter/Pdo/Abstract.php(129): PDO->__construct('mysql:dbname=gl...', 'myDb', '', Array)
#1 /Library/WebServer/sites/testweb/library/Zend/Db/Adapter/Pdo/Mysql.php(96): Zend_Db_Adapter_Pdo_Abstract->_connect()
#2 /Library/WebServer/sites/testweb/library/Zend/Db/Adapter/Abstract.php(858): Zend_Db_Adapter_Pdo_Mysql->_connect()
#3 /Library/WebServer/sites/testweb/library/Zend/Db/Adapter/Abstract.php(928): Zend_Db_Adapter_Abstract->quote('asdf@asd...', NULL)
#4 /Library/WebServer/sites/testweb/library/Zend/Db/Select.php(1000): Zend_Db_Adapter_Abstract->quoteInto('email = ?', 'asdf@asd...', NULL)
#5 /Library/WebServer/sites/testweb/library/Zen in /Library/WebServer/sites/testweb/library/Zend/Db/Adapter/Pdo/Abstract.php on line 144
Run Code Online (Sandbox Code Playgroud)
如果我添加:3306然后它的工作原理
resources.db.params.host = "localhost:3306"
Run Code Online (Sandbox Code Playgroud)
然而,Windows机器有这样的连接问题.
有没有办法让OSX连接只在localhost mysql默认端口?
Dar*_*rke 11
要使用'localhost'作为ip而不是让unix系统尝试连接到套接字,只需提供ip-address而不是'localhost' - 127.0.0.1
resources.db.params.host = 127.0.0.1
Run Code Online (Sandbox Code Playgroud)
要指定端口,必要时应在资源配置中使用单独的行:
resources.db.params.port = 3306
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
8655 次 |
| 最近记录: |