How to fix Access denied for user Error in Laravel [fixed]

Do you know how to fix Access denied for user error in Laravel ? it’s actually a database connection issue. mainly in Cpanel I face this issue many times.

I found a solution for it. First, go to your root directory that contains the .env file open that up.

Your ENV File Database Config

DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=emailsort
DB_USERNAME=root
DB_PASSWORD=password

There you can find the database details something like this.

Adding a single quote on Username and Password will fix the issue. 



and the results should look like this. 

Fixed ENV File Database Config

DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=emailsort
DB_USERNAME='root'
DB_PASSWORD='password'

I just added a single ‘   ‘ quote for DB_USERNAME , DB_PASSWORD values. then it will work perfectly

Hope this helps you.

Post Your Questions on our forum

Post a question on Forum

Ajith Jojo Joseph

Self taught, dedicated young entrepreneur with many licensed products under his sleeve. Passionate about technology, business and excellence in general.

Share with your friends:

Comments are closed.

How to get data from a model on all pages in Laravel – Simple Way

Do you know How to get data from a model on all pages in Laravel ? In this blog post, […]

August 5, 2022

How to create a Laravel Collection From JSON

Today i have to create a laravel collection from a JSON object. I search on the internet and I cant […]

August 3, 2022

Laravel Eloquent WhereNull() and whereNotNull() Example

Do you know how to use WhereNull() and whereNotNull() Laravel Eloquent. In this post, I will explain how to use […]

July 28, 2022

Laravel Array to JSON Response From Laravel Controller

Do you know how to make JSON responses from a Laravel array? As a developer someday we all have to […]

July 28, 2022

Digital Marketing Toolkit

Get Free Access to Digital Marketing Toolkit. You can use all our tools without any limits

Get Free Access Now