Hey everyone,
actually just started to discover percona xtradb with proxysql as lb and pmm. The cluster itself is basically running and now i’m looking how to create a mysql user with privileges for a db and a caching_sha2 password.
So what do i done?
- create database
 - 
create database exampledb;
 - created the user on the cluster:
 - 
CREATE USER 'exampleuser'@'%' IDENTIFIED WITH 'caching_sha2_password' BY 'Ofoonaishoo4raezi6ainah9xi9raedieW6AiMoochooW2Chie';
 - grant permissions
 - 
GRANT ALL PRIVILEGES ON exampledb.* TO 'exampleuser'@'%';
 - flush privs
 - 
FLUSH PRIVILEGES;
 - created user on proxysql
 - 
INSERT INTO mysql_users (username, password, default_hostgroup) VALUES ('exampleuser', '', 1);
 - Got the hex of the password from the cluster
 - 
SELECT HEX(authentication_string) FROM mysql.user WHERE user = 'exampleuser';
 - updated the proxysql users password with the HEX of cluster user:
 - 
UPDATE mysql_users SET password=UNHEX('24412430303524434B59784977416E56565F35645C155A6B68090157314C2E61487976566673476B416F533368456A317646476F4562686B4B316B6134444430576B7A4C2F39') WHERE username='exampleuser';
 - apply and save the configuration:
 - 
LOAD MYSQL USERS TO RUNTIME; SAVE MYSQL USERS TO DISK;
 
When now trying to connect from a client to the user with:
mysql -u exampleuser -p -h pmysql.domain.tld -P6033
I get the following access denied:
ProxySQL Error: Access denied for user 'exampleuser'@'10.1.99.2' (using password: YES)
I used the following documentations for that:
Do i misunderstood something?
//Edit
So the string within mysql_users/password is the same as within the mysql.users/authentication_string.
I’m able to login with exampleuser from and to the cluster nodes, but not with exampleuser from a client to proxysql:6033 to one of the nodes.
//Edit2
As of here:
This option doesn’t disable any of the authentication methods supported by ProxySQL, just allows to optimize the client-server communication during handshake by making the default authentication announced by the server, match the authentication the client is expected to request. Thus avoiding unnecessary
AuthSwitchRequests.This variable overrides mysql-have_ssl, enabling SSL for fronted connections when set to
caching_sha2_password. This is becausecaching_sha2_passwordrequires a safe channel for performing full authentication, due to clear text password sharing.
So as since i’m new to caching_sha2_authentication and just discovered by this, ssl certificate is in need to be able to get a working authentication.
I just thought to change the default to prevent these AuthSwitchRequests and get a cleared error message which i got:
ERROR 2026 (HY000): TLS/SSL error: self-signed certificate in certificate chain
Seems like it does not like the self signed certificate. In the past days i bootstrapped the cluster again - does it generates a new ssl certificate then which i manually need to roll out to all nodes again?
As of here:
The auto-generated files are suitable for automatic SSL configuration, but you should use the same key and certificate files on all nodes.
For SST i already deployed the server-key/cert to all nodes. Do i also need to deploy the same client cert and key to all nodes or do they need their own client cert/key?
//Edit3
Last question: Is it still more applicable to use native_authentication_method when dealing with different type of applications? Not every application supports ssl mysql with cert ^^
//Edit 4
So…The cluster nodes got their server and client ssl-cert/key/ca configuration and a restart. Then i created a client certificate from one of the nodes with these commands:
Then i copied the client-cert, client-key and ca.pem to the clients /etc/mysql folder and configured the my.cnf with:
[client]
ssl-ca=/etc/mysql/ca.pem
ssl-cert=/etc/mysql/client-cert.pem
ssl-key=/etc/mysql/client-key.pem
When now trying to connect to the proxysql i still get:
ERROR 2026 (HY000): TLS/SSL error: self-signed certificate in certificate chain
So after research i found:
So i think this is still missing to be able to work correct… I will give it a try…will take some time…
      