Access Denied for Database although credentials are correct

As I was following this tutorial,

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

Submit an answer

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!

Sign In or Sign Up to Answer

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.

Want to learn more? Join the DigitalOcean Community!

Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in Q&A, subscribe to topics of interest, and get courses and tools that will help you grow as a developer and scale your project or business.

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

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

Regards, KFSys