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

后端 未结 5 359
忘掉有多难
忘掉有多难 2021-01-13 11:03

I try to setup a mysql database in Kubernetes. I configured a ConfigMap to store the Database name and a Secret that contains the root password, the user and the password fo

5条回答
  •  隐瞒了意图╮
    2021-01-13 11:35

    You need to give the access to client machine to connect mysql database.

    replace the address with your desktop ip and run this command on mysql database. then test the connection.

    GRANT ALL PRIVILEGES ON *.* TO 'root'@''   WITH GRANT OPTION;
    GRANT ALL PRIVILEGES ON *.* TO 'root'@'%'   WITH GRANT OPTION;
    FLUSH PRIVILEGES;
    

    The way you created secret is not correct. remove and create it like this. I tested in my cluster it worked.

    kubectl create secret generic db-credentials --from-literal=mysql-root-password=Test1234 --from-literal=mysql-user=testadm --from-literal=mysql-password=Test1234
    

提交回复
热议问题