Kubernetes mysql 8.0.13 do not initialize properly from ENV

12/1/2018

I am using mysql 8.0.13 from docker hub registry. I am not able to connect to the database from within the pod shell. However, I am able to do so when running the docker container on my localhost without using kubernetes. With reference to Can't connect to mysql pod in Kubernetes when using Secrets for password (Access denied), I have tried both setting the root password value inside the manifest and using k8s secret but to no avail. I can't connect to it remotely but I can connect to a local container with the same image remotely. Even setting MYSQL_ALLOW_EMPTY_PASSWORD doesn't work but it works on localhost container without kubernetes.

khteh@khteh-T580:~ 2035 $ k exec -it mysql-0 -- bash
root@mysql-0:/# mysql
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)
root@mysql-0:/# mysql
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)
root@mysql-0:/# mysql -p
Enter password: 
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)
root@mysql-0:/# mysql -p""
Enter password: 
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)
root@mysql-0:/# echo $MYSQL_ROOT_PASSWORD

root@mysql-0:/# 
$ k exec -it mysql-0 -- bash
root@mysql-0:/# mysql -uroot -p$MYSQL_ROOT_PASSWORD
mysql: [Warning] Using a password on the command line interface can be insecure.
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)
root@mysql-0:/# echo $MYSQL_ROOT_PASSWORD
<snip>
root@mysql-0:/# mysql -u$MYSQL_USER -p$MYSQL_PASSWORD
mysql: [Warning] Using a password on the command line interface can be insecure.
ERROR 1045 (28000): Access denied for user 'iconverse'@'localhost' (using password: YES)
root@mysql-0:/# echo $MYSQL_PASSWORD
<snip>
root@mysql-0:/# mysql --version
mysql  Ver 8.0.13 for Linux on x86_64 (MySQL Community Server - GPL)
root@mysql-0:/# 

Any advice and insight is appreciated.

-- Kok How Teh
access-denied
containers
docker
kubernetes
mysql

1 Answer

12/16/2018

I had a similar issue before and not sure why one can't login to MySQL when pod is created. Restarted cluster should solve the issue.

-- Qaiser Ali Bangash
Source: StackOverflow