Skip to content

Conversation

Copy link

Copilot AI commented Feb 1, 2026

MySQL commands fail when DB_HOST, DB_USER, DB_PASSWORD, or DB_CHARSET are defined as empty strings in wp-config.php. Empty values are passed as --host= --user= --default-character-set=, which MySQL rejects with errors like Character set '' is not a compiled character set.

Changes

  • Filter empty parameters in DB_Command::run(): Added array_filter to strip empty strings and null values from the $required array before passing to MySQL commands
  • Preserve valid edge cases: String '0' and integer 0 are kept (valid for ports/values)
  • Add test coverage: New Behat scenario verifies empty DB_CHARSET doesn't generate invalid command-line arguments

Implementation

// Filter out empty string values to avoid passing empty parameters to MySQL commands
// which can cause errors like "Character set '' is not a compiled character set"
$required = array_filter(
    $required,
    static function ( $value ) {
        return null !== $value && '' !== $value;
    }
);

Applies to all commands using the run() method: check, optimize, repair, cli, query, export, import, etc.

Original prompt

This section details on the original issue you should resolve

<issue_title>mysqlcheck: Character set '' is not a compiled character set</issue_title>
<issue_description>## Bug Report
When running commands related to db at hostinger, I get the following error.

mysqlcheck: Character set '' is not a compiled character set and is not specified in the '/usr/share/mysql/charsets/Index.xml' file
Unsupported character set:

Hostinger support said it's a bug with the wp-cli, and my debug shows the same..
Describe the current, buggy behavior

When running wp db check in any of my wp installs at hostinger, I get the following:

$ wp db check
mysqlcheck: Character set '' is not a compiled character set and is not specified in the '/usr/share/mysql/charsets/Index.xml' file
Unsupported character set:

With debug...

$ wp db check --debug
Debug (bootstrap): Processing bootstrap step: WP_CLI\Bootstrap\DeclareAbstractBaseCommand (0.014s)
Debug (bootstrap): Processing bootstrap step: WP_CLI\Bootstrap\IncludeFrameworkAutoloader (0.014s)
Debug (bootstrap): Processing bootstrap step: WP_CLI\Bootstrap\ConfigureRunner (0.014s)
Debug (bootstrap): Processing bootstrap step: WP_CLI\Bootstrap\IncludeRequestsAutoloader (0.014s)
Debug (bootstrap): Setting RequestsLibrary::$version to v2 (0.014s)
Debug (bootstrap): Setting RequestsLibrary::$source to wp-core (0.014s)
Debug (bootstrap): Setting RequestsLibrary::$class_name to \WpOrg\Requests\Requests (0.014s)
Debug (bootstrap): Processing bootstrap step: WP_CLI\Bootstrap\InitializeColorization (0.014s)
Debug (bootstrap): Processing bootstrap step: WP_CLI\Bootstrap\InitializeLogger (0.014s)
Debug (bootstrap): Processing bootstrap step: WP_CLI\Bootstrap\DefineProtectedCommands (0.014s)
Debug (bootstrap): Processing bootstrap step: WP_CLI\Bootstrap\LoadExecCommand (0.014s)
Debug (bootstrap): Processing bootstrap step: WP_CLI\Bootstrap\LoadRequiredCommand (0.015s)
Debug (bootstrap): Processing bootstrap step: WP_CLI\Bootstrap\IncludePackageAutoloader (0.015s)
Debug (bootstrap): Processing bootstrap step: WP_CLI\Bootstrap\IncludeFallbackAutoloader (0.015s)
Debug (bootstrap): Fallback autoloader paths: phar://wp-cli.phar/vendor/autoload.php (0.015s)
Debug (bootstrap): Loading detected autoloader: phar://wp-cli.phar/vendor/autoload.php (0.015s)
Debug (bootstrap): Attaching command 'config edit' to hook before_wp_load (0.022s)
Debug (bootstrap): Attaching command 'config path' to hook before_wp_load (0.022s)
Debug (bootstrap): Attaching command 'config list' to hook before_wp_load (0.022s)
Debug (bootstrap): Attaching command 'config get' to hook before_wp_load (0.022s)
Debug (bootstrap): Attaching command 'config is-true' to hook before_wp_load (0.022s)
Debug (bootstrap): Attaching command 'config set' to hook before_wp_load (0.022s)
Debug (bootstrap): Attaching command 'config delete' to hook before_wp_load (0.022s)
Debug (bootstrap): Attaching command 'config has' to hook before_wp_load (0.022s)
Debug (bootstrap): Attaching command 'config shuffle-salts' to hook before_wp_load (0.022s)
Debug (commands): Adding command: config (0.022s)
Debug (bootstrap): Attaching command 'core download' to hook before_wp_load (0.024s)
Debug (bootstrap): Attaching command 'core version' to hook before_wp_load (0.024s)
Debug (commands): Adding command: core (0.024s)
Debug (bootstrap): Attaching command 'eval' to hook before_wp_load (0.024s)
Debug (commands): Adding command: eval (0.025s)
Debug (bootstrap): Attaching command 'eval-file' to hook before_wp_load (0.025s)
Debug (commands): Adding command: eval-file (0.025s)
Debug (commands): Adding command: cache (0.025s)
Debug (commands): Adding command: transient (0.026s)
Debug (bootstrap): Attaching command 'core verify-checksums' to hook before_wp_load (0.027s)
Debug (commands): Adding command: verify-checksums in core Namespace (0.027s)
Debug (commands): Adding command: plugin (0.027s)
Debug (commands): Adding command: verify-checksums in plugin Namespace (0.027s)
Debug (commands): Adding command: cron (0.028s)
Debug (commands): Adding command: event in cron Namespace (0.028s)
Debug (commands): Adding command: schedule in cron Namespace (0.028s)
Debug (bootstrap): Attaching command 'db' to hook after_wp_config_load (0.03s)
Debug (bootstrap): Attaching command 'db clean' to hook after_wp_load (0.031s)
Debug (bootstrap): Attaching command 'db tables' to hook after_wp_load (0.031s)
Debug (bootstrap): Attaching command 'db size' to hook after_wp_load (0.031s)
Debug (bootstrap): Attaching command 'db prefix' to hook after_wp_load (0.031s)
Debug (bootstrap): Attaching command 'db search' to hook after_wp_load (0.031s)
Debug (bootstrap): Attaching command 'db columns' to hook after_wp_load (0.031s)
Debug (commands): Adding command: db (0.032s)
Debug (commands): Adding command: embed (0.032s)
Debug (commands): Adding command: fetch in embed Namespace (0.032s)
Debug (commands...


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI and others added 2 commits February 1, 2026 19:35
Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix mysqlcheck character set error in wp-cli Filter empty database parameters to prevent MySQL command failures Feb 1, 2026
Copilot AI requested a review from swissspidy February 1, 2026 19:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

mysqlcheck: Character set '' is not a compiled character set

2 participants