I am new to Laravel. I am trying to create a laravel CRUD with resource controllers. However, when I try to run php artisan migrate
I get the following error:
我是Laravel的新手。我正在尝试使用资源控制器创建一个laravel CRUD。但是,当我尝试运行php artisan migrate时,我收到以下错误:
SQLSTATE[HY000] [2002] No such file or directory (SQL: select * from information_schema.tables where table_schema = homestead and table_name = migrations)
SQLSTATE [HY000] [2002]没有这样的文件或目录(SQL:select * from information_schema.tables where table_schema = homestead和table_name = migrations)
Here is my database.php
这是我的database.php
'mysql' => [
'driver' => 'mysql',
'host' => env('DB_HOST', '127.0.0.1'),
'port' => env('DB_PORT', '3306'),
'database' => env('DB_DATABASE', 'design'),
'username' => env('DB_USERNAME', 'homestead'),
'password' => env('DB_PASSWORD', 'secret'),
'unix_socket' => env('DB_SOCKET', ''),
'charset' => 'utf8mb4',
'collation' => 'utf8mb4_unicode_ci',
'prefix' => '',
'strict' => true,
'engine' => null,
],
and this is my env file:
这是我的环境文件:
APP_NAME=Laravel
APP_ENV=local
APP_KEY=base64:hLJn+XHKPjf5qEvROeyMMLIjw56Kg9RkXhZIlbjjne4=
APP_DEBUG=true
APP_LOG_LEVEL=debug
APP_URL=http://localhost
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=design
DB_USERNAME=homestead
DB_PASSWORD=secret
This is a common problem and I have tried many solutions but they wont work. Please help.
这是一个常见问题,我尝试了很多解决方案,但它们无法正常工作。请帮忙。
1 个解决方案
#1
0
try to use PORT 3306 and change localhost to 127.0.0.1
尝试使用PORT 3306并将localhost更改为127.0.0.1
for example
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=
DB_USERNAME=
DB_PASSWORD=
#1
0
try to use PORT 3306 and change localhost to 127.0.0.1
尝试使用PORT 3306并将localhost更改为127.0.0.1
for example
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=
DB_USERNAME=
DB_PASSWORD=