How to connect to DB, when running via command line

点点圈 提交于 2019-12-09 14:54:43

问题


When I run zend framework project from browser, everything is OK, it connects to DB.

When I run project from command line it can't connect to DB and it throws an error:

Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[HY000] [2002] No such file or directory' in /usr/local/zend/share/ZendFramework/library/Zend/Db/Adapter/Pdo/Abstract.php:129

I have used Running a Zend Framework action from command line 's answers ( https://stackoverflow.com/a/4706966/457033 )

It's my application.ini file's db part

phpSettings.mysql.default_socket=/usr/local/zend/mysql/tmp/mysql.sock

resources.db.adapter = "PDO_MYSQL"
resources.db.params.host = "localhost"
resources.db.params.port = 3306
resources.db.params.username = "root"
resources.db.params.password = "root"
resources.db.params.dbname = "iteam"
resources.db.isDefaultTableAdapter = true
resources.db.params.charset = "utf8"

回答1:


Copy the content of application.ini in your php.ini file, this should work fine.



来源:https://stackoverflow.com/questions/8414520/how-to-connect-to-db-when-running-via-command-line

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!