Can't connect to mysql pod in Kubernetes when using Secrets for password (Access denied) Can't connect to mysql pod in Kubernetes when using Secrets for password (Access denied) kubernetes kubernetes

Can't connect to mysql pod in Kubernetes when using Secrets for password (Access denied)


you can use this yaml file.

apiVersion: v1kind: Secretmetadata:   name: db-credentialstype: Opaquedata:  mysql-password: VGVzdDEyMzQ=  mysql-root-password: VGVzdDEyMzQ=  mysql-user: dGVzdGFkbQ==


Are you sure the data in your secret yaml is base64-encoded correctly? Using https://www.base64encode.org/, your data block is supposed to look like:

data:  mysql-root-password: VGVzdDEyMzQ= # Test1234  mysql-user: dGVzdGFkbQ== # testadm  mysql-password: VGVzdDEyMzQ= # Test1234


For anyone having an issue not resolved by line breaks issue as was case with OP here, note that you can't change the mysql password once the database is created. The environment variable is only read when the db is created so if you are using a persistent volume claim you need log in with the old password and change it "manually": https://dev.mysql.com/doc/refman/8.0/en/resetting-permissions.html