[英]Cannot disable mysql login without password on AlpineLinux of Docker container
I am really stuck and I need your help.我真的被困住了,我需要你的帮助。
My project is to build wordpress-installed website with 3 containers: Nginx, Wordpress + php-fpm and mysql on Docker. My project is to build wordpress-installed website with 3 containers: Nginx, Wordpress + php-fpm and mysql on Docker. All containers are built on alpine:latest image.
所有容器都建立在 alpine:latest 镜像上。
I successfully launched website and everything works except for one thing: to disable mysql login without password.我成功启动了网站,一切正常,除了一件事:禁用 mysql 无密码登录。
My mysql's container is working on these condition:我的 mysql 容器正在以下条件下工作:
I believe I have tried enough solutions such as:我相信我已经尝试了足够的解决方案,例如:
SET PASSWORD FOR 'root'@'localhost' = PASSWORD('xxxxxx');
SET PASSWORD FOR 'root'@'localhost' = PASSWORD('xxxxxx');
Yet, I could login without password on root user.然而,我可以在没有密码的情况下登录 root 用户。
This is the screenshot after I did those 3 things.这是我做了这三件事后的截图。
As you can see, root user has passoword but I can login without entering any password on root user.如您所见,root 用户有密码,但我无需在 root 用户上输入任何密码即可登录。
What I want to achive is like this:我想要实现的是这样的:
# mysql - u root
Enter Password: // Just enter 'Enter'
ERROR: Access denied for user 'root'@'localhost' (using password: No)
I do appreciate your help.我很感激你的帮助。
Update: 2021-06-02更新:2021-06-02
I tried to create a similar condition using debian:buster because official mysql docker uses debian:buster-slim. I tried to create a similar condition using debian:buster because official mysql docker uses debian:buster-slim. Here is official mysql image .
这是官方 mysql 图像。
I easily achieved to disable mysql login without password by setting password on root user.通过在root用户上设置密码,我很容易实现禁用mysql无密码登录。
So I wonder if it is because of alpine...所以我想知道是不是因为高山...
There are multiple ways to do it, I am not sure if this will work for accessing the server from application side, but you can access mysql prompt by storing this user and password at OS level.有多种方法可以做到这一点,我不确定这是否适用于从应用程序端访问服务器,但您可以通过在操作系统级别存储此用户和密码来访问 mysql 提示符。
[client] user=root password=somepassword
[client] user=root password=somepassword
shell> mysql_config_editor set --login-path=dbadmin_local --host=localhost --user=dbadmin --password Enter password:
You can add multiple hostnames and passwords by changing the login path.您可以通过更改登录路径来添加多个主机名和密码。 If the password is changed, you can run this utility again, which updates the password in the file:
如果密码已更改,您可以再次运行此实用程序,它会更新文件中的密码:
shell> mysql_config_editor set --login-path=dbadmin_remote -- host=35.186.157.16 --user=dbadmin --password Enter password:
If you want to log in to 35.186.157.16 using the dbadmin user, you can simply execute mysql --login-path=dbadmin_remote:如果要使用 dbadmin 用户登录 35.186.157.16,只需执行 mysql --login-path=dbadmin_remote:
shell> mysql --login-path=dbadmin_remote
外壳> mysql --login-path=dbadmin_remote
To connect to localhost, you can simply execute mysql要连接到 localhost,您只需执行 mysql
shell> mysql
外壳> mysql
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.