I'm trying to setup a Laravel 10 application on DigitalOcean with a Managed Database. I have an nginx server up and running on the droplet and can access the website by it's domainname. However I can't connect to the Managed Database as can be seen in the screenshot below when I try to migrate the tables:
What I have so far is:
- Configured the server according to: https://www.digitalocean.com/community/tutorials/initial-server-setup-with-ubuntu-22-04
- Installed LEMP stack according to: https://www.digitalocean.com/community/tutorials/how-to-install-linux-nginx-mysql-php-lemp-stack-on-ubuntu-22-04, but skipped the installation of MySql as in the prerequisites of the “How to Set Up a Scalable Laravel 6 Application using Managed Databases and Object Storage” tutorial.
- Installed the MySQL client, created a Mysql user and database according to https://www.digitalocean.com/community/tutorials/how-to-set-up-a-scalable-laravel-6-application-using-managed-databases-and-object-storage#step-2-creating-a-new-mysql-user-and-database
- Installed Composer, NodeJS and NPM
- Created a Managed Database in the DO control panel. ( In the same VPC as the droplet)
- Added the droplet to the trusted sources.
- Added domains and dns settings in the DO control panel
- Installed LetsEncrypt SSL certificate.
These are the settings I use:
.env
Which come straight from the DO control panel:
/config/database.php
Location of the CA certificate;
Furhtermore I'm able login the mysql server inside the droplet and create database users and tables .
I really would appreciate any help on this. I'm currently kind of clueless after searching for hours on the internet.






After very long searching and debugging I found that there were already database variables defined in /etc/environment.
I guess DigitalOcean puts it there when you create your droplet and have the "add a managed database" checkbox checked. However I ended up deleting it and creating another managed database.
So the database in my .env file in my application were overruled by the ones defined in the /etc/environment file.