Closed hanny007 closed 1 year ago
since the mysql-client works , I think it's golang mysql driver's issue ?
since the mysql-client works , I think it's golang mysql driver's issue ?
I'm not sure. mysql-client and go app may use different way to connect db. Please provide complete step to reproduce.
Note that this driver is used by many Gophers. If there is a simple auth bug, many users would reported it already. "I can connect with mysql cli" highly likely mean mysql cli used different auth method or different network protocol (unix vs TCP, or plain vs TLS).
Without complete step to reproduce, I assume it is your configuration issue and will close this issue.
@methane I encounter the same problems. Mysqlworkbench worked, but code not. I use the same user(root), and password is empty. both tcp and ip and port.
What is your exact code and error you seen? How did you checked your MySQL Workbench uses TCP? Describe complete step, exact command/step you used and what you seen is needed.
Without them, "me too" is just a spam to me.
@methane sorry, my fault. in my case, the db have password, but my code have not input it. MySQL Workbench have store password before. So when i test again, even when I have not input password, it also worked.
It is why complete step to reproduce is necessary. Without it, issue reports and "me too" are just spam notification and noise in issue tracker.
Issue description
I have a mysql(version 8.0) running on my local server (host) I also have one golang service ,want it to use this mysql, and I set my service container using
docker run --network=host myapp
as network=host mode ,hoping I could use 127.0.0.1 to connect my mysql
but I got panic: Error 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)
I 've tried many ips , no one works
and I even download mysql-client in the container , and it works for mysql-client , so I am sure it's not because wrong user or password .
Example code
Error log
Configuration
image : golang 1.19
*Driver version (or git SHA): I just use go mod tidy
*Go version: 1.19
*Server version: 8.0.31-0ubuntu0.20.04.1
Server OS: Ubuntu 20.04