问题描述
我是laravel的新手,正在尝试运行迁移,但是它向我显示以下错误:
I am new to laravel and trying to run the migration but it showing me following error:
SQLSTATE [HY000] [1045]用户'root'@'localhost'的访问被拒绝(使用密码:否)(SQL:从informati on_schema.tables中选择*其中table_schema = test1,table_name =迁移)
SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost' (using password: NO) (SQL: select * from informati on_schema.tables where table_schema = test1 and table_name = migrations)
在Connector.php第67行中:
In Connector.php line 67:
SQLSTATE [HY000] [1045]用户'root'@'localhost'的访问被拒绝(使用密码:否)
SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost' (using password: NO)
推荐答案
这是数据库连接错误.
解决方案:
如果您使用的是Windows计算机,并且默认情况下XAMPP可以使用
If you are using a windows machine and XAMPP by default can use
DB_CONNECTION=mysql
DB_HOST=localhost
DB_PORT=3306
DB_DATABASE=db_name
DB_USERNAME=root
DB_PASSWORD=
如果您使用的是Linux计算机,并且默认情况下可以使用XAMPP,请确保该DB用户没有密码.否则,您必须在 .env
If you are using a Linux machine and XAMPP by default can use also make sure the DB user has no password. Otherwise, you have to give DB password in .env
DB_CONNECTION=mysql
DB_HOST=localhost
DB_PORT=3306
DB_DATABASE=db_name
DB_USERNAME=root
DB_PASSWORD=password
别忘了使用artisan命令 php artisan config:cache
清除缓存.(如果您在env中进行了任何更改,则拥有清晰的配置缓存)
Don't forget to clear the cache using php artisan config:cache
artisan command.(if you made any changes in env you have clear config cache)
这篇关于Laravel显示用户拒绝错误访问的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!