简体   繁体   English

ampps / Laravel5:错误:用户'root'@'localhost'拒绝访问

[英]ampps/Laravel5: error:Access denied for user 'root'@'localhost'

I install laravel 5.2 on Ampps (windows 10) with this tutorial. 我使用本教程在Ampps(windows 10)上安装了laravel 5.2

it works. 有用。

But Now I want connect to mysql. 但现在我想连接到mysql。

I create a 'test1' DB and change these two files: 我创建了一个'test1'DB并更改了这两个文件:

config/database.php 配置/ database.php中

mysql' => [
            'driver'    => 'mysql',
            'host'      => env('DB_HOST', 'localhost'),
            'database'  => env('DB_DATABASE', 'test1'),
            'username'  => env('DB_USERNAME', 'root'),
            'password'  => env('DB_PASSWORD', ''),
            'charset'   => 'utf8',
            'collation' => 'utf8_unicode_ci',
            'prefix'    => '',
            'strict'    => false,
        ],

.env .ENV

DB_HOST=localhost
DB_DATABASE=test1
DB_USERNAME=root
DB_PASSWORD=

After that I restart apache. 之后我重启apache。

then in CMS I run this code: 然后在CMS中运行此代码:

F:\Ammps\www\quickstart>php artisan migrate

But I get this error: 但我得到这个错误:

 error SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost' 

I think I miss a step. 我想我错过了一步。

can please help me? 能帮帮我吗?

According to the Ampps FAQ you need the default mysql password: 根据Ampps FAQ,您需要默认的mysql密码:

1. Default MySQL root password is "mysql".

So add that to your .env file like this: 所以将它添加到.env文件中,如下所示:

DB_HOST=localhost
DB_DATABASE=test1
DB_USERNAME=root
DB_PASSWORD=mysql

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 用户'root'@'localhost'的访问被拒绝 - Laravel - Access denied for user 'root'@'localhost' - Laravel Laravel 用户“root”@“localhost”的宅基地访问被拒绝 - Laravel homestead access denied for user "root"@"localhost" Laravel 拒绝用户'root'@'localhost' PHP 8.1.6 Laravel 9.14.1 访问 - Laravel Access denied for user 'root'@'localhost' PHP 8.1.6 Laravel 9.14.1 laravel 5用户“ root” @“ localhost”的访问被拒绝(使用密码:是) - laravel 5 Access denied for user 'root'@' localhost' (using password: YES) MYSQL错误:拒绝用户'root'@'localhost'的访问(1045) - MYSQL error: Access denied for user 'root'@'localhost' (1045) XAMPP PhpMyAdmin错误1045,“用户'root'@'localhost'的访问被拒绝 - XAMPP PhpMyAdmin Error 1045, "Access denied for user 'root'@'localhost' 用户'root'@ localhost mysql错误1045拒绝访问 - access is denied for user 'root'@localhost mysql error 1045 数据库连接错误用户'root'@'localhost'的访问被拒绝(使用密码:否) - Database connection error Access denied for user 'root'@'localhost' (using password: NO) 用户'root'Laravel的访问被拒绝 - Access denied for user 'root' Laravel 用户'root'@'localhost'的访问被拒绝(使用密码:NO) - Access denied for user 'root'@'localhost' (using password: NO)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM