TheRobotLearns Platform · ProxySQL: from first install to production

Configuring Users, Authentication Methods, and Password Constraints

  • about 15 min read

Learning objectives

  • Explain how ProxySQL separates frontend client-to-proxy and backend proxy-to-database authentication.
  • List supported ProxySQL frontend methods, including caching_sha2_password, SPIFFE, and LDAP.
  • List backend authentication methods ProxySQL supports, including mysql_native_password and caching_sha2_password.
  • Set mysql-default_authentication_plugin and apply MySQL variable changes to the runtime.
  • Explain password-format caveats, including * passwords causing authentication detection failures.
  • Configure ProxySQL users through the mysql_users table.

Separate Client and Backend Auth

For a client connecting to ProxySQL, ProxySQL uses the frontend authentication direction. ProxySQL supports distinct authentication mechanisms depending on the connection direction.

The first direction is frontend: clients to ProxySQL. The second direction is backend: ProxySQL to databases. Each direction has its own list of supported methods.

The frontend list includes mysql_native_password, mysql_clear_password, caching_sha2_password, SPIFFE, and LDAP. SPIFFE is a passwordless X.509 certificate-based authentication method. LDAP is a directory-based authentication method.

The backend list includes mysql_native_password, mysql_clear_password, and caching_sha2_password. The backend list does not include SPIFFE or LDAP. In the backend list, mysql_native_password and mysql_clear_password are supported in all versions. The backend list also gives caching_sha2_password full support from v2.6.0.

The frontend and backend lists are separate. SPIFFE and LDAP are frontend entries without a matching backend entry.

Takeaway: ProxySQL separates client-to-proxy and proxy-to-database authentication into two supported-method lists.

Frontend Methods and Versions

The frontend direction covers clients connecting to ProxySQL. Its method list includes mysql_native_password, mysql_clear_password, caching_sha2_password, SPIFFE, and LDAP.

mysql_native_password and mysql_clear_password are supported in all versions. caching_sha2_password has full support from v2.6.0. In v2.0.2 through v2.5.x, frontend caching_sha2_password requires passwords stored in cleartext. Before v2.0.2, caching_sha2_password has no support at all.

SPIFFE is a passwordless X.509 certificate-based method. LDAP is a directory-based method.

The backend direction covers ProxySQL connecting to databases. Its list includes mysql_native_password, mysql_clear_password, and caching_sha2_password. For backend authentication, mysql_native_password and mysql_clear_password are supported in all versions. caching_sha2_password has full backend support from v2.6.0.

v2.6.0 and later have full caching_sha2_password support for both directions. The two lists overlap only on those three listed methods.

Takeaway: Frontend adds SPIFFE and LDAP, while backend accepts native, clear, and caching_sha2_password with caching_sha2_password support from v2.6.0.

Change the Plugin, Load Runtime

You change mysql-default_authentication_plugin, but the change must be explicitly loaded to the runtime before it takes effect.

mysql-default_authentication_plugin is a MySQL variable. To set the default authentication plugin to mysql_native_password, use:

SET mysql-default_authentication_plugin='mysql_native_password';
LOAD MYSQL VARIABLES TO RUNTIME;
SAVE MYSQL VARIABLES TO DISK;

Remember to use the appropriate LOAD and SAVE commands to activate and persist your configuration.

Takeaway: SET mysql-default_authentication_plugin='mysql_native_password' sets the variable, LOAD MYSQL VARIABLES TO RUNTIME loads it into the runtime, and SAVE MYSQL VARIABLES TO DISK persists it.

Watch Password Formats and Handshakes

You configure users through mysql_users, and passwords starting with * may cause authentication detection failures. Authentication method switching during handshakes can create challenges for caching_sha2_password.

MariaDB clients using caching_sha2_password require the --ssl flag for versions before MariaDB 10.10. COM_CHANGE_USER, including mysql_change_user() and connection-pool reset by change user, fails in several cases for caching_sha2_password clients.

On Stable v3.0 and Innovation/AI-MCP up to v3.1.12 or v4.0.12, these cases fail. From v3.1.13 or v4.0.13, ProxySQL authenticates the new user like a new connection would.

mysql-have_ssl is true by default since v2.6.0. mysql-add_ldap_user_comment, when set, adds a comment containing the frontend username to the query.

The added comment has the form valueof_mysql-add_ldap_user_comment=frontend_username. mysql-ldap_user_variable, when set, gives sessions a variable with the user name for backend-side auditing. For example, it can appear as SET @mysql-ldap_user_variable:='username'.

Takeaway: mysql_users configures users, and * passwords can break detection while caching_sha2_password affects handshakes, MariaDB client flags, and change-user paths.

Apply a MySQL Variable Change

-- Users are configured in mysql_users.
SET mysql-default_authentication_plugin='mysql_native_password';
LOAD MYSQL VARIABLES TO RUNTIME;
SAVE MYSQL VARIABLES TO DISK;

The comment names the table where users are configured. SET mysql-default_authentication_plugin='mysql_native_password'; sets the default authentication plugin to the value shown in the configuration example. LOAD MYSQL VARIABLES TO RUNTIME; moves the changed MySQL variables into the runtime. SAVE MYSQL VARIABLES TO DISK; persists the configuration with the SAVE command.

Try it: config_layer_sim

Run these admin commands in order:

SET mysql-default_authentication_plugin='mysql_native_password';
LOAD MYSQL VARIABLES TO RUNTIME;

After the SET, the change is not live until the LOAD applies MySQL variables to the runtime. Add SAVE MYSQL VARIABLES TO DISK to persist the configuration. Users are configured in the mysql_users table.

Sources

Do more with an account

Configuring Users, Authentication Methods, and Password Constraints — ProxySQL: from first install to production