使用 Artisan 的 Laravel 迁移设置失败
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/14219692/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Laravel setup of migrations using Artisan is failing
提问by Toby
I am trying to set up migrations for the first time and when I run
我正在尝试第一次和运行时设置迁移
php artisan migrate:install
from within the root folder of my project I get the following SQLSTATE error:
从我的项目的根文件夹中,我收到以下 SQLSTATE 错误:
SQLSTATE[HY000] [2002] No such file or directory
I have tested running mysql
to make sure it is working and referenced and I have ran php artisan help:commands
to make sure artisan is working (it is).
我已经测试运行mysql
以确保它正常工作并被引用,并且我已经运行php artisan help:commands
以确保工匠正在工作(它是)。
The website itself is functioning and reading from the database fine.
该网站本身正在运行并且从数据库中读取正常。
回答by J.T. Grimes
This may be an issue with the sockets if you're using MAMP or XAMPP.
如果您使用 MAMP 或 XAMPP,这可能是套接字的问题。
From http://forums.laravel.io/viewtopic.php?id=980...
从http://forums.laravel.io/viewtopic.php?id=980...
'connections' => array(
'mysql' => array(
'driver' => 'mysql',
'host' => 'localhost',
'unix_socket' => '/Applications/MAMP/tmp/mysql/mysql.sock',
'database' => 'database',
'username' => 'user',
'password' => 'pass',
'charset' => 'utf8',
'prefix' => '',
),
),
You can pass an optional "unix_socket" to the array and specify the MAMP socket instead of the default location.
您可以将可选的“unix_socket”传递给数组并指定 MAMP 套接字而不是默认位置。
回答by Edwin M
Also, try and change 'host' => 'localhost', to 'host'=> '127.0.0.1', because unix does not recognise 'localhost'
另外,尝试将 'host' => 'localhost', 更改为 'host'=> '127.0.0.1',因为 unix 无法识别 'localhost'