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. All containers are built on alpine:latest image.
I successfully launched website and everything works except for one thing: to disable mysql login without password.
My mysql's container is working on these condition:
I believe I have tried enough solutions such as:
SET PASSWORD FOR 'root'@'localhost' = PASSWORD('xxxxxx');
Yet, I could login without password on root user.
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.
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
I tried to create a similar condition using debian:buster because official mysql docker uses debian:buster-slim. Here is official mysql image .
I easily achieved to disable mysql login without password by setting password on root user.
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.
[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:
shell> mysql --login-path=dbadmin_remote
To connect to localhost, you can simply execute mysql
shell> mysql
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.