错误提示如下:
SQLSTATE[HY000] [2002] No such file or directory 错误位置 FILE: /var/www/baite/core/Library/Think/Db/Driver.class.php LINE: 109 TRACE #0 /var/www/baite/core/Library/Think/Db/Driver.class.php(109): E('SQLSTATE[HY000]...') #1 /var/www/baite/core/Library/Think/Db/Driver.class.php(1061): ThinkDbDriver->connect() #2 /var/www/baite/core/Library/Think/Db/Driver/Mysql.class.php(50): ThinkDbDriver->initConnect(true) #3 /var/www/baite/core/Library/Think/Model.class.php(136): ThinkDbDriverMysql->getFields('qs_hooks') #4 /var/www/baite/core/Library/Think/Model.class.php(124): ThinkModel->flush() #5 /var/www/baite/core/Library/Think/Model.class.php(1453): ThinkModel->_checkTableInfo() #6 /var/www/baite/core/Library/Think/Model.class.php(99): ThinkModel->db(0, '', true) #7 /var/www/baite/app/Common/Model/HooksModel.class.php(18): ThinkModel->__construct('Hooks', '', '') #8 /var/www/baite/core/Common/functions.php(595): CommonModelHooksModel->__construct('Hooks') #9 /var/www/baite/app/Behaviors/InitHookBehavior.class.php(20): D('Hooks') #10 /var/www/baite/core/Library/Think/Hook.class.php(121): BehaviorsInitHookBehavior->run(NULL) #11 /var/www/baite/core/Library/Think/Hook.class.php(91): ThinkHook::exec('Behaviors\InitH...', 'run', NULL) #12 /var/www/baite/core/Library/Think/App.class.php(191): ThinkHook::listen('app_init') #13 /var/www/baite/core/Library/Think/Think.class.php(121): ThinkApp::run() #14 /var/www/baite/core/ThinkPHP.php(96): ThinkThink::start() #15 /var/www/baite/tp.php(98): require('/var/www/baite/...') #16 /var/www/baite/FrameSelector.php(6): require('/var/www/baite/...') #17 /var/www/baite/www/index.php(5): FrameSelector::load() #18 {main}
数据库配置文件如下:
APP_ENV=local APP_DEBUG=True DB_CONNECTION=mysql DB_HOST=localhost DB_PORT=3306 DB_DATABASE=baite DB_USERNAME=root DB_PASSWORD=root DB_PREFIX=qs_ ELASTICSEARCH_HOSTS=
其实,是配置错误将DB_HOST的值改为mysql:
APP_ENV=local APP_DEBUG=True DB_CONNECTION=mysql DB_HOST=mysql DB_PORT=3306 DB_DATABASE=baite DB_USERNAME=root DB_PASSWORD=root DB_PREFIX=qs_ ELASTICSEARCH_HOSTS=
ok,问题解决