ERROR 2059 (HY000): Authentication plugin 'mysql_native_password' cannot be loaded when using cf mysql plugin
search cancel

ERROR 2059 (HY000): Authentication plugin 'mysql_native_password' cannot be loaded when using cf mysql plugin

book

Article ID: 437742

calendar_today

Updated On:

Products

VMware Tanzu for MySQL

Issue/Introduction

When attempting to use the cf mysql plugin on a macOS environment with a local MySQL client installed via Homebrew, the command fails with the following error:

mysql: [Warning] Using a password on the command line interface can be insecure.ERROR 2059 (HY000): Authentication plugin 'mysql_native_password' cannot be loaded: dlopen(/opt/homebrew/Cellar/mysql/9.6.0_2/lib/plugin/mysql_native_password.so, 0x0002): tried: '/opt/homebrew/Cellar/mysql/9.6.0_2/lib/plugin/mysql_native_password.so' (no such file)FAILEDerror running mysql client: exit status 1

Environment

Operating System: macOS (Apple Silicon/Homebrew)

MySQL Client Version: 9.0 or higher (e.g., 9.6.0)

Tool: Cloud Foundry CLI (cf) with mysql plugin

Cause

As of MySQL 9.0, the mysql_native_password authentication plugin has been removed and is no longer included in the MySQL distribution.

The cf mysql plugin (or the database user it is connecting as) is still configured to use the legacy mysql_native_password method. Because the local MySQL 9.x client binaries do not contain the .so library for this plugin, the dlopen call fails when the client attempts to initialize the authentication handshake.

Resolution

Option 1: Downgrade Local MySQL Client (Recommended)

Since the cf mysql plugin relies on the local mysql binary, downgrade the local client to MySQL 8.4, which still supports the native password plugin.

  1. Uninstall the current MySQL version:
    brew uninstall mysql
  2. Install the Long-Term Support (LTS) MySQL 8.4 client:
    brew install [email protected]
  3. Link the older version so it is available in your PATH:
    brew link --force [email protected]

Option 2: Update Database User Authentication

If you have administrative access to the MySQL service instance, update the user to use the newer caching_sha2_password plugin, which is supported by MySQL 9.x clients.

  1. Connect to the MySQL instance using a compatible client.
  2. Execute the following SQL command:
    ALTER USER 'your-username'@'%' IDENTIFIED WITH caching_sha2_password BY 'your-password';FLUSH PRIVILEGES;

Option 3: Manual Configuration (If applicable)

If using a MySQL 8.x server, ensure the plugin is explicitly enabled in the server configuration (my.cnf or my.ini):

[mysqld]mysql_native_password=ON