我刚刚开始使用 Laravel Forge,但在 SSH 连接到服务器后,我似乎无法登录 MySQL。每次我尝试:
mysql -uforge -p
Enter password: thepassword
我收到此错误:
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)
我已经使用 Forge 设置了我的环境变量,所以它不应该使用默认值:
DB_HOST=thehostip
DB_DATABASE=forge
DB_USERNAME=forge
DB_PASSWORD=theotherpassword
我将数据库配置保留为:
'default' => env('DB_CONNECTION', 'mysql'),
'connections' => [
'mysql' => [
'driver' => 'mysql',
'host' => env('DB_HOST', 'localhost'),
'database' => env('DB_DATABASE', 'forge'),
'username' => env('DB_USERNAME', 'forge'),
'password' => env('DB_PASSWORD', ''),
'charset' => 'utf8',
'collation' => 'utf8_unicode_ci',
'prefix' => '',
'strict' => false,
],
...
],