Hi there,
As far as I’m concerned, there must be a problem connecting to your database.
It’s an error generated by WordPress.
Are you sure of the info in your .env?
I am sure it is not related to the database or credentials. Here is why:
As I explained, the error happened right after a successful wp installation when I clicked on the login link at the bottom of “successful installation” page. If my “.env” was erroneous, I wouldn’t be able to install WP.
I created a simple test.php page to test my credentials connecting to database and it connected successfully.
And the problem occured many times (I can say at least 7), so I posted my question on this forum.
I would recommend to search for ”Error establishing a database connection” in the WP core files and then debug from there.
That message can occur even if the problem isnt really with the database connection, for example if you are running a multisite with wrong values in wp_blogs/wp_site.
The problem was that at certain point in wp-includes/functions.php, wordpress looks for the ‘siteurl’ from ‘wp_options’ table, but for some reason this option was not populated during installation process!
The solution was that I populated my ‘home’ and ‘siteurl’ variables in the ‘wp_options’ table using phpmyadmin and voila. Now I can see the wordpress login form.
‘home’ is normally for homepage address, and ‘siteurl’ is for the wp core files: {home}/wp.