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=local
APP_DEBUG=true
APP_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=2525
MAIL_USERNAME=null
MAIL_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
相关文章
- 数据库事务,游标,触发器,存储过程,索引,数字,日期转换为字符,字符串操作,查询,分类,内连接,外连接,全连接,模糊查询,范围查询,5种聚合函数,分组查询,主键,外键,标识列
- jsp JDBC连接MySQL数据库操作标准流程参考
- STS工具:mybayis连接oracle数据库
- 3种PHP连接MYSQL数据库的常用方法
- Oracle可插拔数据库的jdbc连接串写法
- 数据库、计算机网络,操作系统刷题笔记6
- C#连接MYSQL数据库并进行查询
- 数据库SQL优化大总结之 百万级数据库优化方案
- 数据库常用命令笔记
- Sae配置Java数据库连接
- Navicat Premium连接Oracle数据库报错
- oracle数据库无法连接 The Network Adapter could not establish
- PHP数据库长连接mysql_pconnect的细节
- 使用Visual Studio的动态连接库创建通用数据库连接对话框
- 嵌入式数据库事务理解以及实例操作
- 配置PL/SQL Developer连接server数据库
- GoLang 连接 Mysql 数据库
- 数据库水平拆分和垂直拆分区别
- SQL Server数据库快照的工作方式
- 数据库查询之内连接,左连接,右连接