【发布时间】:2017-10-17 07:18:49
【问题描述】:
我是 Laravel 的新手(5.5 版)。这是 config/database.php 文件:
'mysql' => [
'driver' => 'mysql',
'host' => env('DB_HOST', '127.0.0.1'),
'port' => env('DB_PORT', '3306'),
'database' => env('DB_DATABASE', 'mfa'),
'username' => env('DB_USERNAME', 'root'),
'password' => env('DB_PASSWORD', 'mypass'),
'unix_socket' => env('DB_SOCKET', ''),
'charset' => 'utf8',
'collation' => 'utf8_unicode_ci',
'prefix' => '',
'strict' => true,
'engine' => null,
],
这是我在 routes/web.php 上的路线:
Route::get('/', function ()
{
Schema::create('books',function($newtable){
$newtable->increments('id');
$newtable->string('writer');
$newtable->string('title',500);
$newtable->text('description');
$newtable->date('published');
$newtable->integer('copies');
$newtable->timestamps();
});
return view('welcome');
});
数据库存在,名为'mfa',用户名是'root'。尽管它是“root”,但它似乎正在尝试以“homestead”身份登录。这是一个错误代码:SQLSTATE[HY000] [1045]
【问题讨论】:
-
检查一下你的
.env文件存在于你的 laravel 项目的根目录中 -
检查
.env文件或环境变量。 -
出现错误后,我也编辑了。更改后错误保持不变。 /.env:
-
@smus 你能分享你的
.envfile 代码吗 -
查看mysql用户和每个用户对数据库的分配
标签: php laravel-5.5