I have installed mysql-client in my Mac by the following command:
brew install mysql-client
And when I run the following command:
mysql -h 127.0.0.1 -u root -p
An ERROR 1045 occured:
ERROR 1045 (28000): Access denied for user 'root'@'172.17.0.1' (using password: NO)
but when I use Sequel Pro
I can login the local mysql server.
Why the 127.0.0.1 becomes 172.17.0.1 ?
I run this command on local host iTerm. I use the docker pull to pull a mysql:5.7 image from docker registry:
docker run --name mysql -e MYSQL_ROOT_PASSWORD=xxxxxx -d -p 0.0.0.0:3306:3306 mysql:5.7
And the mysql container is just running, then I use Sequel Pro GUI client to connect into the database in docker, and it works. And then I try to use
brew install mysql-client
to install the mysql command (because I want to use it to run a sql file to prepare data for my project's tests suite). after installed mysql-client, i use the command
mysql -h 127.0.0.1 -u root -p
try to connect database, but it promote the
**ERROR 1045 (28000): Access denied for user 'root'@'172.17.0.1'
(using password: NO)**.
I did not do any configuration for the mysql docker container.
After hours try and search, finally I found the solution:
mysql -h 127.0.0.1 -P 3306 -u root -p
you need a -P
parameter
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With