報錯信息如下:
:(
SQLSTATE[HY000] [2002] No such file or directory
錯誤位置
FILE: /phpstudy/www/mmm/ThinkPHP/Library/Think/Db/Driver.class.php LINE: 109
TRACE
#0 /phpstudy/www/mmm/ThinkPHP/Library/Think/Db/Driver.class.php(109): E('SQLSTATE[HY000]...')
#1 /phpstudy/www/mmm/ThinkPHP/Library/Think/Db/Driver.class.php(1075): Think\Db\Driver->connect()
#2 /phpstudy/www/mmm/ThinkPHP/Library/Think/Db/Driver/Mysql.class.php(47): Think\Db\Driver->initConnect(true)
#3 /phpstudy/www/mmm/ThinkPHP/Library/Think/Model.class.php(138): Think\Db\Driver\Mysql->getFields('inkks_xin')
#4 /phpstudy/www/mmm/ThinkPHP/Library/Think/Model.class.php(126): Think\Model->flush()
#5 /phpstudy/www/mmm/ThinkPHP/Library/Think/Model.class.php(1458): Think\Model->_checkTableInfo()
#6 /phpstudy/www/mmm/ThinkPHP/Library/Think/Model.class.php(101): Think\Model->db(0, '', true)
#7 /phpstudy/www/mmm/ThinkPHP/Common/functions.php(621): Think\Model->__construct('xin', '', '')
#8 /phpstudy/www/mmm/appx/Home/Controller/IndexController.class.php(9): M('xin')
#9 [internal function]: Home\Controller\IndexController->index()
#10 /phpstudy/www/mmm/ThinkPHP/Library/Think/App.class.php(173): ReflectionMethod->invoke(object(Home\Controller\IndexController))
#11 /phpstudy/www/mmm/ThinkPHP/Library/Think/App.class.php(110): Think\App::invokeAction(object(Home\Controller\IndexController), 'index')
#12 /phpstudy/www/mmm/ThinkPHP/Library/Think/App.class.php(204): Think\App::exec()
#13 /phpstudy/www/mmm/ThinkPHP/Library/Think/Think.class.php(120): Think\App::run()
#14 /phpstudy/www/mmm/ThinkPHP/ThinkPHP.php(97): Think\Think::start()
#15 /phpstudy/www/mmm/index.php(7): require('/phpstudy/www/m...')
#16 {main}問題出在mysql.sock這個進程socket連接文档的位置沒有定義, 系統就會報找不到文档。
解決方案: 調整php.ini和my.cnf
一般主機環境都把mysql.sock這個文档扔到/tmp目錄下, 那麽路徑就是/tmp/mysql.sock
php.ini裡加一行
pdo_mysql.default_socket=/tmp/mysql.sock
my.conf裡相關的配置爲
socket=/tmp/mysql.sock