laravel 5连接MySQL_laravel5 数据库连接问题

[PDOException] SQLSTATE[28000] [1045] Access denied for user ‘homestead’@’localhost’ (using password: YES) looks like same error different is not showing any file line number.

The reason of Access denied for user ‘homestead’@’localhost’ laravel 5 error is caching-issue of the .env.php file cause Laravel 5 is using environment based configuration in your .env file.

Why Environment Configuration :-

It’s often helpful to have different configuration values based on the environment the application is running in. For example, you may wish to use a different cache driver locally than you do on your production server. It’s easy using environment based configuration.

Laravel utilizes the DotEnv PHP library by Vance Lucas. In fresh Laravel installation, you will see a .env.example file in the root directory of your application. If you are installing Laravel via Composer, this file will automatically be renamed to .env. else, you need to rename the file manually. For more about Environment Configuration

default .env file looks like :-

APP_ENV=localAPP_DEBUG=trueAPP_KEY=your_key

DB_HOST=localhost

DB_DATABASE=homestead

DB_USERNAME=homestead

DB_PASSWORD=secret

CACHE_DRIVER=file

SESSION_DRIVER=file

QUEUE_DRIVER=sync

MAIL_DRIVER=smtp

MAIL_HOST=mailtrap.io

MAIL_PORT=2525MAIL_USERNAME=nullMAIL_PASSWORD=null

How to solve this error :- let’s see how we can solve this PDOException in Connector.php line 47: SQLSTATE[28000] [1045] Access denied for user ‘homestead’@’localhost’ (using password: YES) error in laravel 5.

1. Go to your application root directory and open .env file (In ubuntu may be it’s hidden so press ctrl+h to show hidden files) in your editor and change database configuration setting. then save your .env file

DB_HOST=localhost

DB_DATABASE=laravelu

DB_USERNAME=root

DB_PASSWORD=''

2. then restart your apache server/web server. and refresh your page and you have done

3. If still issue try to run below command to clear the old configuration cache file.

php artisan config:clear

Now run your user register page and enjoy new laravel 5. Now you are done with Access denied for user ‘homestead’@’localhost’ laravel 5

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值