Report this

What is the reason for this report?

Access Denied for Database although credentials are correct

Posted on April 25, 2021

As I was following this tutorial,

https://www.digitalocean.com/community/tutorials/automatically-deploy-laravel-applications-deployer-ubuntu

Everything is perfectly done except the database connection. During deploy, at migrate stage, it seems the env credentials provided is not able to establish a connection with the server itself.

  • Laravel 8
  • MySQL 8
  • PHP 7.4
  • Ubuntu 20 These are the specs


This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Hi @risingsoul1991,

Can you try using the following command to see if you would be able to connect to the database :

mysql -u laravel_db_user -p laravel_db -h localhost

You’ll need to change laravel_db_user and laravel_db with the actual information of course.

If it doesn’t work, most probably your password is not correct. To change it, you can use the following

mysql
ALTER USER 'laravel_db_user '@'localhost' IDENTIFIED BY 'New-Password-Here';

Regards, KFSys

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Get started for free

Sign up and get $200 in credit for your first 60 days with DigitalOcean.*

*This promotional offer applies to new accounts only.