Laravel重启后无法连接到本地MySQL?

时间:2014-03-19 10:10:07

标签: laravel

从那时起,我重新启动了我的VPS服务器,我的日志消息中出现错误:

    [2014-03-14 10:18:04] log.ERROR: exception 'PDOException' with message 'SQLSTATE[HY000] [2002] Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (111)' in /home/cap-store/vendor/laravel/framework/src/Illuminate/Database/Connectors/Connector.php:47
Stack trace:
#0 /home/cap-store/vendor/laravel/framework/src/Illuminate/Database/Connectors/Connector.php(47): PDO->__construct('mysql:host=loca...', 'root', 'Rincewind', Array)
#1 /home/cap-store/vendor/laravel/framework/src/Illuminate/Database/Connectors/MySqlConnector.php(20): Illuminate\Database\Connectors\Connector->createConnection('mysql:host=loca...', Array, Array)
#2 /home/cap-store/bootstrap/compiled.php(6611): Illuminate\Database\Connectors\MySqlConnector->connect(Array)
#3 /home/cap-store/bootstrap/compiled.php(6538): Illuminate\Database\Connectors\ConnectionFactory->make(Array, 'mysql')
#4 /home/cap-store/bootstrap/compiled.php(6512): Illuminate\Database\DatabaseManager->makeConnection('mysql')
#5 /home/cap-store/bootstrap/compiled.php(6400): Illuminate\Database\DatabaseManager->connection(NULL)
#6 /home/cap-store/bootstrap/compiled.php(6387): Illuminate\Database\Eloquent\Model::resolveConnection(NULL)
#7 /home/cap-store/bootstrap/compiled.php(6025): Illuminate\Database\Eloquent\Model->getConnection()
#8 /home/cap-store/bootstrap/compiled.php(5998): Illuminate\Database\Eloquent\Model->newBaseQueryBuilder()
#9 /home/cap-store/bootstrap/compiled.php(5612): Illuminate\Database\Eloquent\Model->newQuery()
#10 /home/cap-store/app/controllers/HomeController.php(7): Illuminate\Database\Eloquent\Model::find(1)
#11 [internal function]: HomeController->getIndex()
#12 /home/cap-store/vendor/laravel/framework/src/Illuminate/Routing/Controllers/Controller.php(138): call_user_func_array(Array, Array)
#13 /home/cap-store/vendor/laravel/framework/src/Illuminate/Routing/Controllers/Controller.php(115): Illuminate\Routing\Controllers\Controller->callMethod('getIndex', Array)
#14 /home/cap-store/bootstrap/compiled.php(4927): Illuminate\Routing\Controllers\Controller->callAction(Object(Illuminate\Foundation\Application), Object(Illuminate\Routing\Router), 'getIndex', Array)
#15 [internal function]: Illuminate\Routing\Router->Illuminate\Routing\{closure}()
#16 /home/cap-store/bootstrap/compiled.php(8117): call_user_func_array(Object(Closure), Array)
#17 /home/cap-store/bootstrap/compiled.php(8104): Illuminate\Routing\Route->callCallable()
#18 /home/cap-store/bootstrap/compiled.php(4938): Illuminate\Routing\Route->run(Object(Illuminate\Http\Request))
#19 /home/cap-store/bootstrap/compiled.php(533): Illuminate\Routing\Router->dispatch(Object(Illuminate\Http\Request))
#20 /home/cap-store/bootstrap/compiled.php(520): Illuminate\Foundation\Application->dispatch(Object(Illuminate\Http\Request))
#21 /home/cap-store.com/index.php(49): Illuminate\Foundation\Application->run()
#22 {main} [] []

不明白故障在哪里。我只重启了服务器。

1 个答案:

答案 0 :(得分:1)

这不是Laravel的错误。检查VPS上的mysql实例,确保你的mysql服务正在运行。

我认为您没有将mysql服务设置为自动启动VPS。