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 create Laravel Flash Messages

Laravel flash messages are a convenient way to display one-time notifications to the user after a form submission or other […]

December 22, 2022

How to make Custom Artisan Command in Laravel

Custom Artisan commands are a useful feature of Laravel that allow you to define your own command-line commands for tasks […]

December 22, 2022

Tips for Laravel migrations

Laravel migrations are a powerful tool for managing and modifying your database schema in a structured and organized way. Here […]

December 22, 2022

Tricks and tips for Laravel blade templating

Welcome to our blog about tricks and tips for Laravel blade templating! Blade is the default templating engine for Laravel, […]

December 22, 2022

Digital Marketing Toolkit

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

Get Free Access Now