-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Access denied for user 'testuser'@'172.17.0.1' (using password: YES) #230
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Localhost is handled differently by MySQL, as it goes through the local unix socket instead of the network interface. To test you can change your grant statement to 'testuser'@'%' and you should see the connection succeed, but then anything with access to your host's 6604 port can connect |
'testuser'@'172.17.0.1' should also work (172.17.0.1 being the default ip for the host computer), but that ip might change. |
I see this issue when I create accounts too early. In my first iteration of provisioning I did the following:
The problem here seems to lie with the fact that container restarts the server at least three times. I suspect my script is run sometime after the first restart, and privileges are not truly flushed. The users exist, but my containers cannot connect as those users. If I wait 20 seconds, until after the third restart, to run my user creation script my containers have no issue connecting to the databases. The fact that a new container restarts the server three times needs to be documented so that folks are aware of this, and can work around it appropriately. |
Related: #245 |
@clintonb Can you do the user init by putting your user creation script in the container's /docker-entrypoint-initdb.d/ directory instead? It's meant to be used for this kind of initialization, and any .sql or .sh files you map to that location will be run as part of the first startup. The server doesn't start three times in a connectable manner. It runs with --initialize once, but it won't accept any connections then. The main init is done by starting the server with --skip-networking, so it won't accept external connections, but at this point it's possible to connection through the exec command you use, which is the main problem. At least for 5.7+ I want to try replacing this way of doing init with using the --init-file functionality, which should prevent people from connecting before the container is ready |
ran into the same issue. The problem was related to docker-compose where I needed to use a hash instead of a list for environment variable definition. In case you had the same and didn't show you were using compose. |
I think I've got a similar problem. I am running this image along with another docker image (eboraas/apache-php) for my PHP app. I am using Phinx for migrations. The MySQL image seems to work fine as I can connect to it as 'dbuser' (non-root) using MySQL Workbench. I can also connect with Docker exec as well. Problem occurs when I try to run any Phinx command, such as status. I'm getting:
I have tried running the migration from the host as well as in the PHP container...both give me an error. My grants on the DB look like:
My development section of the
Finally, here is my
Any ideas? |
@maclonghorn |
the password you see in the GRANTS was created when I created the container, as per the Environment Variables. does that look wrong/suspicious? I could try to update the pwd via CLI. |
@maclonghorn, Where are you running the Phinx commands? If you are running it on the host, are you also running a local mysql server that it might be connecting to via unix socket rather than the one in docker on port 3306? Maybe you need to switch to |
I had tried running both from host and from within container -- neither worked, but had different errors. I did have MySQL running on the host, so I shut that down. I'm now able to run |
web & mysql services not in the save network can cause error: Access denied for user 'summer'@'172.25.0.9' (using password: YES) for example app service connect to db service:
|
Face the same issue, after running the mysql container.
Worked For me:
use the select query to get the hash value of the stored password in user table. Now u can access root user from host machine, one can also grant access to other users as per need. Thanks. |
Closing given that the original issue appears to be solved. For further help debugging issues with deploying this image, I'd recommend posting to the Docker Community Forums, the Docker Community Slack, or Stack Overflow. Thanks! |
check you config/database.php maybe changed user name and password |
I ran into this error after setting up a laravel app in a virtual machine. The app uses a local and an external database. After trying different solutions, I wrapped the remote password in my env file in double quotes. This solved the issue. Apparently the password could not be properly read without the wrapping quotes. |
Thanks for this useful info. 'username'@'%' solved my Access Denied issue in MySQL 5.7. |
Ok so say you have a user nextclouddb - this is my local MariaDB instance (actual server DB) - and I wanted my docker nextcloud to be able to access it - This worked MariaDB [nextcloud]> grant all on nextcloud to 'nextclouddb'@'%'; MariaDB [nextcloud]> grant all on . to 'nextclouddb'@'%'; |
Thank you, this was really fault of the password change: |
I had this issue connecting from a .NET6 WebAPI app. Tried to use root but it wouldn't take. Created another user and it worked fine. appsettings.json
|
Hello,
I have created a mysql docker container thus :
docker run
--detach
--name=mysql-test
--env="MYSQL_ROOT_PASSWORD=test"
--volume=/Docker/mysql-cleanweb/config/conf.d:/etc/mysql/conf.d
--volume=/Docker/mysql-cleanweb/storage/:/var/lib/mysql
--publish 6604:3306
mysql:latest
I have a java app which, amongst other things, can create both users and schemas via SQL. My app creates a 'testschema' and a 'testuser'@'localhost' and grants 'testuser' all privileges on 'testschema' :
CREATE DATABASE testschema;
GRANT ALL PRIVILEGES ON testschema.* TO 'testuser'@'localhost:6604' IDENTIFIED BY 'testuser'
FLUSH PRIVILEGES;
Unfortunately when my app tries to connect to this schema as 'testuser' it fails. Using testuser / testuser for jdbc://mysql://localhost:6604/testschema I get "Access denied for user 'testuser'@'172.17.0.1' (using password: YES)".
I've googled around about this and tried using 'testuser'@'localhost' and '172.17.0.1:6604' but still no solution in sight.
Your help would be most appreciatated!
Thanks
Anthony
The text was updated successfully, but these errors were encountered: