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 integrate Paypal API in Laravel

Are you looking to integrate Paypal API in your Laravel project for seamless payment processing? Look no further! In this […]

April 3, 2024

How to integrate Razorpay API in Laravel

Integrating payment gateways into web applications has become an essential part of e-commerce websites. In this tutorial, we will discuss […]

April 3, 2024

Laravel 11 Ajax CRUD Operation Tutorial Example

**Mastering CRUD Operations with Laravel 11 Ajax: A Comprehensive Tutorial** In the world of web development, interaction between the front-end […]

April 3, 2024

Login as Client in Laravel – Login with user id

**Unlock the Power of Laravel with Login as Client – Login with User ID** Laravel, the popular PHP framework, offers […]

April 3, 2024

Digital Marketing Toolkit

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

Get Free Access Now