kubernetes mysql 8.0.13无法从env正确初始化

yduiuuwa  于 2021-06-18  发布在  Mysql
关注(0)|答案(1)|浏览(785)

我正在使用docker hub注册表中的MySQL8.0.13。我无法从荚壳内连接到数据库。但是,我可以在本地主机上运行docker容器而不使用kubernetes。关于在kubernetes中使用secrets作为密码时无法连接mysql pod(拒绝访问),我尝试了在清单中设置根密码值和使用k8s secret,但都没有效果。我无法远程连接到它,但我可以远程连接到具有相同映像的本地容器。即使设置mysql\u allow\u empty\u密码也不起作用,但是它可以在没有kubernetes的localhost容器上工作。

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:/#

任何建议和见解都将不胜感激。

ie3xauqp

ie3xauqp1#

我以前也遇到过类似的问题,不知道为什么创建pod时不能登录mysql。重启的集群应该可以解决这个问题。

相关问题