Warning: mysqli_real_connect(): (HY000/2002): No such file or directory in /var/www/html/web/wp/wp-includes/wp-db.php on line 1548
olafghanizadeh opened this issue · 2 comments
After setting up DockPress I get this error when starting the container.
Warning: mysqli_real_connect(): (HY000/2002): No such file or directory in /var/www/html/web/wp/wp-includes/wp-db.php on line 1548
Hey @olafghanizadeh! Sorry to hear you had trouble setting this up. I cloned the repo and ran through a fresh start to see if I could replicate and didn't run into that error.
Can you share more details about how you started the container?
I'm guessing that the error is related to the values you have set in src/.env
since this is related to the initial DB connection. The exact line referenced in your error from wp-db.php can be seen here: https://github.com/WordPress/WordPress/blob/4.8.2/wp-includes/wp-db.php#L1548
This connection depends on setting the values in the src/.env
file to match what the develop script from DockPress uses. I cover this briefly in the accompanying blog post for DockPress: https://joepurdy.io/words/dockerize-wordpress-with-roots.io/#setting-the-environment-variables
Here's an example of the .env
file configured to match the defaults that the develop script uses:
DB_NAME=wordpress
DB_USER=wordpress
DB_PASSWORD=secret
DB_HOST=mysql
# Optional variables
# DB_PREFIX=wp_
WP_ENV=development
WP_HOME=http://example.dev
WP_SITEURL=${WP_HOME}/wp
# Generate your keys here: https://roots.io/salts.html
AUTH_KEY='generateme'
SECURE_AUTH_KEY='generateme'
LOGGED_IN_KEY='generateme'
NONCE_KEY='generateme'
AUTH_SALT='generateme'
SECURE_AUTH_SALT='generateme'
LOGGED_IN_SALT='generateme'
NONCE_SALT='generateme'
Let me know if you still have trouble getting up and running and I'll work on improving the documentation for how to configure the environment correctly.
I'm closing this since I never heard back regarding replication steps.
If this is still a problem for you @olafghanizadeh please leave a comment here with your replication steps and I'd be happy to help further!