There is a cluster 8.0.36-28.1 of 3 nodes.
By default, the caching_sha2_password
plugin is there.
The problem is that when creating a new user, each node has its own password hash.
What it looks like:
- create a user on 1 node:
CREATE USER 'sha2user'@'%' IDENTIFIED BY 'qwerty';
- check the hash on each node:
1 node:
mysql> select user,host,plugin,authentication_string from mysql.user where user = 'sha2user';
+----------+------+-----------------------+------------------------------------------------------------------------+
| user | host | plugin | authentication_string |
+----------+------+-----------------------+------------------------------------------------------------------------+
| sha2user | % | caching_sha2_password | $A$005$
Q~1>{a!s%riRZl?"pjsNMud0lsc8AMRfcuyLoA93GuBUun.8gLcS5qi015C |
+----------+------+-----------------------+------------------------------------------------------------------------+
1 row in set (0,00 sec)
2 node:
mysql> select user,host,plugin,authentication_string from mysql.user where user = 'sha2user';
+----------+------+-----------------------+------------------------------------------------------------------------+
| user | host | plugin | authentication_string |
+----------+------+-----------------------+------------------------------------------------------------------------+
| sha2user | % | caching_sha2_password | $A$005$d3W\-zx▒Y!H)mmf90LtOdN1mA0gLiFVt5NQg/pRnP7g74i64m0WdXd/ |
+----------+------+-----------------------+------------------------------------------------------------------------+
1 row in set (0,00 sec)
3 node:
mysql> select user,host,plugin,authentication_string from mysql.user where user = 'sha2user';
+----------+------+-----------------------+------------------------------------------------------------------------+
| user | host | plugin | authentication_string |
+----------+------+-----------------------+------------------------------------------------------------------------+
| sha2user | % | caching_sha2_password | $A$005$T1Cyt"Z0^
!x+BlrMLoI2txdrMKPgI7mNJ1w15qAAzSDaLq0wlgAsbe7 |
+----------+------+-----------------------+------------------------------------------------------------------------+
1 row in set (0,00 sec)
- caching_sha variables:
mysql> show variables like 'caching_sha2%';
+----------------------------------------------+-----------------+
| Variable_name | Value |
+----------------------------------------------+-----------------+
| caching_sha2_password_auto_generate_rsa_keys | ON |
| caching_sha2_password_digest_rounds | 5000 |
| caching_sha2_password_private_key_path | private_key.pem |
| caching_sha2_password_public_key_path | public_key.pem |
+----------------------------------------------+-----------------+
4 rows in set (0,01 sec)
The PCA key is different:
1 node:
*************************** 1. row ***************************
Variable_name: Caching_sha2_password_rsa_public_key
Value: -----BEGIN PUBLIC KEY-----
MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAx4OmmTwJjTonPNwTn81h
Qx21eO0LtqPOoXXvEfLF1V1V9TfTNdhH97ls/nI1oBTm7srG1vwC0gThII9sgIdG
DGKD7ECReTUecPe33NOtKAZ13w+82asWhVWFlOSISjMsXEmRPO0jgfS4VG3EIl6A
eChmDaD/ktFvz9yQsmEJHs2YgwOOHbEIIvy+JDoZKCB3awUvV0JvFpXJcTISUsBD
cj+UZM3OQ3ctLrMgyYZeuDlKuf08TrtULxmW66Dgslb0B8i5Wcbl6qhRlQwWdQFS
abOA5G3gaSblKzZuUVU/AmNSzh9T9UQyFqV+iGf89QMn/aTsIV6IoFbYCsh5IrCZ
LwIDAQAB
-----END PUBLIC KEY-----
2 node:
mysql> SHOW STATUS LIKE 'Caching_sha2_password_rsa_public_key'\G
*************************** 1. row ***************************
Variable_name: Caching_sha2_password_rsa_public_key
Value: -----BEGIN PUBLIC KEY-----
MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA5jjtmoRCSOJTvhY4Gt5q
+EpUdD4+LhXpTKkQo5YdjnXMEnw9SRgIROGUEfIFiSd/kY+RhfL2w1k/2wB6LkmD
5EIIkKM4hdJ3mzxU2xbT1TAAjsfDCJOZdl+lR5MUkO7cRQOQWf7s8QtLOfuzwovs
4Ag4h2jzBEGfvSt3clBekd0c39F922/rFJZuxCihOFlI3yYtzBwXUY7yGvCDetUg
AY1l2zR1bwOH9RWL2hlHHDRE52xMrAnITrcHdGwdjwcGpRnsP9EpI1tLdJYc91Eb
7jm4STQfxsj7c5PTCUjyuPsDDjHxLxSiP3Z3YC6XiCfNtxcBG7NGHr+K7W025jHf
JQIDAQAB
-----END PUBLIC KEY-----
3 node:
mysql> SHOW STATUS LIKE 'Caching_sha2_password_rsa_public_key'\G
*************************** 1. row ***************************
Variable_name: Caching_sha2_password_rsa_public_key
Value: -----BEGIN PUBLIC KEY-----
MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAyGgKBQZNAvG/cVr6F/LK
olowOZbw1BkGfHL6QWWxPVIPOjLRkIhpS2wfPTy1AzJ1m/qFnAQaN4ojzjr4TojA
DGBVrr39JhkkCIxp+YwfJ29p8+R98kJJazCd1KG+VhHaBXeS0JvrsAffsSfT39NB
y229E0Eb8z0PRrWF6PsjaGc9Iev9LxA8OxvXBBL54IM3XXymgYgNrgWXBofK4SpU
6b8vfCxasuWoDeMnavOdUMM4tbmspO1HrTw8jIZFOd3UBICd/nLwnEy0sHbn+D/J
7ZwACygsM20YP1wSuY2qSUwfApnzzmzSXsQk1+xVk/cG0cY06SUvTQXuEHxkggE1
CwIDAQAB
-----END PUBLIC KEY-----
ProxySQL is installed in front of the nodes and the mysql_users
table contains users with a password hash (password
field).
This is a problem, there must be one hash.
I believe this is due to the default caching_sha2_password_auto_generate_rsa_keys=ON
variable. Which, according to the documentation, automatically generates a PCA key pair on the server.
We recently had an update from version 8.0.33-25.1 to 8.0.36-28 (04/03/2024).
All users there still use the mysql_native_password
plugin, which is outdated and seems to have been removed in version 9.0.
How to safely and correctly update users to the caching_sha2_password
plugin and solve the problem with different hash and PCA keys?
Will it be enough to take the already generated pair of PCA keys and rewrite them on nodes 2 and 3? And set the variable caching_sha2_password_auto_generate_rsa_keys=OFF
?
We don’t use SSL.
We need to solve this before updating on the production environment, so as not to break the operation of the cluster.
I’m currently testing this in a test environment.