config-command icon indicating copy to clipboard operation
config-command copied to clipboard

DB-Check fails if Database requires SSL

Open Iridias opened this issue 4 years ago • 2 comments

Bug Report

Describe the current, buggy behavior Executing any config-command, that checks the database, e.g. wp config create will result in the following error, if the database requires SSL: ERROR 9002 (28000): SSL connection is required. Please specify SSL options and retry.

Even if you specify:

--extra-php <<PHP
define('MYSQL_CLIENT_FLAGS', MYSQLI_CLIENT_SSL);
PHP

...because the check is not using PHP, but rather:

// Check DB connection.
		if ( ! Utils\get_flag_value( $assoc_args, 'skip-check' ) ) {
			Utils\run_mysql_command( '/usr/bin/env mysql --no-defaults', $mysql_db_connection_args );
		}

(where mysql_db_connection_args is hardcoded) and there is currently no way to specify/inject an addition parameter like --ssl!

Describe how other contributors can replicate this bug

Create a MySQL-DB that requires SSL (for Azure-MySQL there is button "Enforce SSL connection") And then try wp config create with valid credentials.

Describe what you would expect as the correct outcome Working MySQL-Connection.

Let us know what environment you are running this on environment independent.

Provide a possible solution

Either respect the addition PHP define('MYSQL_CLIENT_FLAGS', MYSQLI_CLIENT_SSL); or provide a parameter to enable SSL! wp db export seems to have such an option: https://github.com/wp-cli/db-command/issues/126#issuecomment-692876201

Iridias avatar Oct 08 '20 12:10 Iridias

Also an issue for Digital Ocean's hosted MySQL service. I'd love to see this implemented as well.

adamsewell avatar Dec 28 '20 03:12 adamsewell

Open to reviewing a pull request if someone would like to create one. Here is some guidance on our pull request best practices.

danielbachhuber avatar Apr 26 '23 20:04 danielbachhuber