I want to transfer my website from linux to Windows (wamp server).
I configured my .env file, my virtual hosts and hosts files but when i want to connect to my website i have this message :
var/www/html/merci/web/app/plugins/query-monitor/wp-content/db.php
Error establishing a database connection
What kind of software/server/solution are you using for hosting the WordPress site on Windows?
Container-based (Docker Desktop)/on WSL (2)?
XAMPP?
Some other solution?
So the PHP(-FPM) must be able to connect and authentify with the MySQL server.
Are the database configuration fields in .env correct (database username, database password, database host, database port, database name)?
Was a database created on the MySQL server for that site and an user added/assigned to it with sufficient permissions (create tables, alter tables, …)?
Yes, I have a database and the .env configuration is correct :
DB_NAME='omerci'
DB_USER='admin'
DB_PASSWORD='admin'
# Optionally, you can use a data source name (DSN)
# When using a DSN, you can remove the DB_NAME, DB_USER, DB_PASSWORD, and DB_HOST variables
#DATABASE_URL='mysql://admin:admin@localhost:80/omerci'
# Optional database variables
# DB_HOST='localhost'
# DB_PREFIX='wp_'
WP_ENV='development'
WP_HOME='http://omerci.dev'
WP_SITEURL="${WP_HOME}/wp"
This database connection error in relation to a WAMPP server brings up some workarounds:
So the database host (DB_HOST environment variable) should be changed from its default (localhost) to an IPv4 loopback address (127.0.0.1) (not all localhost resolve equal).
[19-Jun-2022 17:56:33 UTC] PHP Fatal error: Uncaught Error: Class 'Config' not found in C:\wamp64\www\omerci\backend\web\app\db.php:5
Stack trace:
#0 C:\wamp64\www\omerci\backend\web\wp\wp-includes\load.php(549): require_once()
#1 C:\wamp64\www\omerci\backend\web\wp\wp-settings.php(124): require_wp_db()
#2 C:\wamp64\www\omerci\backend\web\wp-config.php(9): require_once('C:\\wamp64\\www\\o...')
#3 C:\wamp64\www\omerci\backend\web\wp\wp-load.php(55): require_once('C:\\wamp64\\www\\o...')
#4 C:\wamp64\www\omerci\backend\web\wp\wp-blog-header.php(13): require_once('C:\\wamp64\\www\\o...')
#5 C:\wamp64\www\omerci\backend\web\index.php(6): require('C:\\wamp64\\www\\o...')
#6 {main}
thrown in C:\wamp64\www\omerci\backend\web\app\db.php on line 5
I don’t understand from where come this file “db.php” and what is his function. Maybe it’s a mistake from I
I deleted it just for seeing but it the same result.
Yes, I m using a recent Bedrock.
I think also it’s a plugin or mistake because I reinstalled other site in the same configuration and there is not problem.
Thank you for your Help @strarsis
db.php is what’s called a “dropin plugin”. They’re poorly documented, but that file is almost certainly added by a plugin. I can’t speculate which one, but you could look at its content, or disable all plugins, delete dp.php and the selective re-enable plugins and see which one cases the file to be added.