Error establishing a database connection using wp-cli
-
I have a container deployed in an Azure App Service that has WP-CLI also installed. My wp-config.php gets the database info using the getenv_docker environment variables. And therefore WP CLI fails to establish a connection to the mysql database also running in Azure.
I have spent 2 days searching and obviously am not searching for the right info as I can not find a solution to allow wp-cli to be able to read the wp-config.php correctly or find another way to pass the database info to wp-cli to know where the database exists.
Can someone please help point me into the right direction?
My wp-config.php looks like this for the DB info.
==================================================================================
/** MySQL hostname */
define( ‘DB_HOST’, getenv_docker(‘WORDPRESS_DB_HOST’, ‘mysql’) );
/** The name of the database for WordPress */
define( ‘DB_NAME’, getenv_docker(‘WORDPRESS_DB_NAME’, ‘wordpress’) );/** MySQL database username */ define( 'DB_USER', getenv_docker('WORDPRESS_DB_USER', 'example username') ); /** MySQL database password */ define( 'DB_PASSWORD', getenv_docker('WORDPRESS_DB_PASSWORD', 'example password') ); ================================================================================== Additional note... it appears since getenv_docker is not working it is trying to use default info... Of course that will not work. :(
# wp config list –allow-root
+———————+——————————————+———-+
| name | value | type |
+———————+——————————————+———-+
| table_prefix | bv_ | variable |
| configExtra | | variable |
| DB_NAME | wordpress | constant |
| MYSQL_CLIENT_FLAGS | 2048 | constant |
| DB_USER | example username | constant |
| DB_PASSWORD | example password | constant |
| DB_HOST | mysql | constant |
| DB_CHARSET | utf8 | constant |`
- The topic ‘Error establishing a database connection using wp-cli’ is closed to new replies.