Question

Error connecting droplet to database

Hello support, Currently I have one droplet and 2 Database Clusters in my account, Droplet is connecting to Database Cluster 1, but now I want droplet to connect to database 2, I have changed the connection information of database 2 in .env file in my laravel project, at the same time I also changed the database information in /etc/environment file and /root/.digitalocean_dbaas_credentials file but my project still connects to database 1, I don’t understand why, can you please provide documentation for me to handle this?


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.

KFSys
Site Moderator
Site Moderator badge
December 16, 2024

Heya,

That’s weird. Where is your Laravel Project deployed? Is it on a Droplet or on the App Platform?

Also, try giving a wrong password to see if you are still going to connect. If you do, then that means either the changes are not taking effect or the credentials are being taken from someplace else.

alexdo
Site Moderator
Site Moderator badge
December 16, 2024

Heya, @v2vnit

Laravel may cache the .env file. After updating the .env file, clear and refresh the configuration cache. You can also try to connect to the dataabse to check if the login credentials are correct.

https://docs.digitalocean.com/products/databases/mysql/how-to/connect/

Hope that this helps!

Become a contributor for community

Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.

DigitalOcean Documentation

Full documentation for every DigitalOcean product.

Resources for startups and SMBs

The Wave has everything you need to know about building a business, from raising funding to marketing your product.

Get our newsletter

Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.

New accounts only. By submitting your email you agree to our Privacy Policy

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.