Skip to content

MySQL 8.0 authentication plugins

MySQL 8.0 introduces changes to the default authentication mechanism compared to previous versions.^[600-developer-database-mysql-mysql8-portable.md]

Default authentication plugin

By default, MySQL 8.0 uses the caching_sha2_password plugin.^[600-developer-database-mysql-mysql8-portable.md]

Native password plugin

To maintain compatibility with older clients or existing setups, MySQL 8.0 can be configured to use the mysql_native_password plugin.^[600-developer-database-mysql-mysql8-portable.md]

Configuration

To set mysql_native_password as the default authentication plugin, the default_authentication_plugin variable must be defined in the my.ini (or my.cnf) configuration file under the [mysqld] section.^[600-developer-database-mysql8-portable.md:32-33]

[mysqld]
default_authentication_plugin=mysql_native_password

User account configuration

When creating or modifying users, authentication plugins can be explicitly assigned.^[600-developer-database-mysql-mysql8-portable.md]

For example, the following command alters the root user to use mysql_native_password and sets the password to 'root':^[600-developer-database-mysql-mysql8-portable.md:21]

ALTER USER 'root'@'%' IDENTIFIED WITH mysql_native_password BY 'root';

Sources

^[600-developer-database-mysql-mysql8-portable.md]