Home > database >  MySQL created with Helm can't connect with non root user
MySQL created with Helm can't connect with non root user

Time:06-02

I am trying to connect to database I have deployed with Helm. What I have is a mysql.yaml file:

auth:
  database: db_host
  username: hamuto
  password: motdepasse
  rootPassword: rootpass
image:
  debug: true

I install my MySQL database with the command: ✅

helm install mysql bitnami/mysql -f mysql.yaml -f mysql-pv.yaml -f mysql-pvc.yaml

What happens when the MySQL is deployed:

This will then output some commands to connect to the database:

echo Username: root
MYSQL_ROOT_PASSWORD=$(kubectl get secret --namespace default mysql -o jsonpath="{.data.mysql-root-password}" | base64 --decode)

  • If I try to echo the variable MYSQL_ROOT_PASSWORD I get the password rootpass. ✅
  • If I try the same thing with the MYSQL_PASSWORD non root password, by changing the jsonpath, I can find the password motdepasse. ✅

I run a pod as a client with the command: ✅

kubectl run mysql-client --rm --tty -i --restart='Never' --image docker.io/bitnami/mysql:8.0.29-debian-10-r15 --namespace default --env MYSQL_ROOT_PASSWORD=$MYSQL_ROOT_PASSWORD --command -- bash

Inside the pod, I run the following command to connect to the database as root : ✅

mysql -h mysql.default.svc.cluster.local -uroot -p"$MYSQL_ROOT_PASSWORD"

The issue:

Trying to connect with non root user doesn't work. ❌

mysql -h mysql.default.svc.cluster.local -u hamuto -pmotdepasse

Doesn't work. ❌

I have checked the helm file template with the command:

helm template mysql .

Nothing weird was shown.

CodePudding user response:

I had a Persistent Volume, when I deleted the mysql with :

helm delete mysql

The PV and PVC stayed, which prevented the new user to be created. I just had to delete it, so I did:

kubectl delete pvc --all

  • Related