SQLSTATE[HY000] [2002] No such file or directory

错误提示如下:

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): Think\Db\Driver->connect()
#2 /var/www/baite/core/Library/Think/Db/Driver/Mysql.class.php(50): Think\Db\Driver->initConnect(true)
#3 /var/www/baite/core/Library/Think/Model.class.php(136): Think\Db\Driver\Mysql->getFields('qs_hooks')
#4 /var/www/baite/core/Library/Think/Model.class.php(124): Think\Model->flush()
#5 /var/www/baite/core/Library/Think/Model.class.php(1453): Think\Model->_checkTableInfo()
#6 /var/www/baite/core/Library/Think/Model.class.php(99): Think\Model->db(0, '', true)
#7 /var/www/baite/app/Common/Model/HooksModel.class.php(18): Think\Model->__construct('Hooks', '', '')
#8 /var/www/baite/core/Common/functions.php(595): Common\Model\HooksModel->__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): Behaviors\InitHookBehavior->run(NULL)
#11 /var/www/baite/core/Library/Think/Hook.class.php(91): Think\Hook::exec('Behaviors\\InitH...', 'run', NULL)
#12 /var/www/baite/core/Library/Think/App.class.php(191): Think\Hook::listen('app_init')
#13 /var/www/baite/core/Library/Think/Think.class.php(121): Think\App::run()
#14 /var/www/baite/core/ThinkPHP.php(96): Think\Think::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,问题解决

 

posted @ 2019-05-07 11:38  大道至简,小而蕴真  阅读(4006)  评论(0编辑  收藏  举报