phpmysql error - #1273 - #1273 - Unknown collation: 'utf8mb4_general_ci'

phpmysql error - #1273 - #1273 - Unknown collation: 'utf8mb4_general_ci'

  1. Blog
  2. 15 November 2026
  3. 3 min read

Stefan Bogdanescu

Founder & Senior Architect

Resolving MySQL Error #1273: Unknown Collation 'utf8mb4_general_ci'

The error #1273 - Unknown collation: 'utf8mb4_general_ci' is a classic symptom of a version mismatch between your PHP application logic and the actual MySQL server configuration. It often manifests when upgrading a database engine from 5.5 to 5.6 or later, where the default character set shifts from utf8 to utf8mb4. If your client-side code or administration tools are hardcoded to expect specific defaults that no longer exist in the server's context, you hit this wall immediately upon connection or schema creation.

In the scenario involving PhpMyAdmin v4.1.5, the issue stems from how the application determines default character set and collation values. The provided source material highlights a check in DatabaseInterface.class.php:

if (PMA_MYSQL_INT_VERSION > 50503) {
    $default_charset = 'utf8mb4';
    $default_collation = 'utf8mb4_general_ci';
} else {
    $default_charset = 'utf8';
    $default_collation = 'utf8_general_ci';
}

At first glance, this logic seems sound: it attempts to detect the MySQL version and assign compatible defaults. However, this code assumes that every MySQL server running version 5.6+ automatically supports utf8mb4_general_ci. This is not always true. While utf8mb4 became the default character set in MySQL 5.7, many servers upgraded from 5.5 to 5.6 retained utf8 as the default character set and did not immediately adopt utf8mb4_general_ci as a valid collation without explicit server-side configuration or recompilation of the server with specific plugins enabled.

When you connect locally on your PC, your local MySQL instance is likely running a version where utf8mb4_general_ci exists by default, so the error never triggers. However, upon connecting to the remote server, if that instance was upgraded from 5.5 to 5.6 without updating its character set configuration, it still considers utf8 as the standard. When PhpMyAdmin tries to enforce utf8mb4_general_ci against a server that doesn't recognize it, MySQL returns error #1273.

To resolve this, you cannot simply patch the PHP code blindly; you must align the client expectations with the server reality. The most robust fix involves inspecting the remote server's current configuration. Run the following query on your remote MySQL instance:

SHOW VARIABLES LIKE 'character_set_database';
SHOW VARIABLES LIKE 'collation_server';
SHOW VARIABLES LIKE 'character_set_filesystem';

If character_set_database returns utf8, you have two paths forward. You can either configure the server to adopt utf8mb4 as the default, or you can adjust your application logic to respect the existing defaults.

For a quick fix in PhpMyAdmin without altering the server immediately, you can manually override the configuration variables in config.inc.php. Instead of relying on automatic detection which might guess wrong, explicitly set the defaults to match the server's actual state:

$cfg['DefaultCharset'] = 'utf8'; // Change this if your server uses utf8mb4
$cfg['Collation']         = 'utf8_general_ci'; // Or use a collation that exists on the server

However, relying on utf8 is technically a legacy choice. The modern standard is utf8mb4, which supports emojis and special characters used in modern applications. If you are building new projects or maintaining existing ones intended for long-term stability, forcing the server to utf8mb4 is preferable. You can do this by setting:

ALTER DATABASE your_database_name
  CHARACTER SET = utf8mb4
  COLLATE = utf8mb4_general_ci;

If the server still throws an error stating the collation is unknown, it indicates that the specific version of MySQL or its build does not support utf8mb4_general_ci. In older 5.6 builds, you might need to use utf8_unicode_ci as a fallback until the server is updated or rebuilt with full UTF-8 support.

When integrating these changes into a larger ecosystem, such as a Laravel application, ensure your .env file reflects these settings:

DB_CHARSET=utf8mb4
DB_COLLATION=utf8mb4_general_ci

If you are deploying via a PPA or package manager, remember that the mysql-server package might need to be restarted for new character set variables to take effect globally. Always test these changes on a staging environment first, as altering default collations can impact existing string comparisons and full-text search indexes across your database.

Our network