Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Access denied when trying to access a mysql just created container

in Mac OS X, I just created a fresh mysql container with:

docker run -d --name my_db -p 13306:3306 -e MYSQL_ROOT_PASSWORD=root -e MYSQL_DATABASE=mydatabase -e MYSQL_USER=myuser -e MYSQL_PASSWORD=secret mysql:8

I want to access the command line interface like I would do with a local mysql, so I did:

$docker exec -it my_db mysql -uroot -p=root 
mysql: [Warning] Using a password on the command line interface can be insecure.
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)
$

I tried dozens of variants, using myuser as the user instead of root, asking chatgpt…just can’t figure out…

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

The mysql documentation states:

–password[=password], -p[password]

The password of the MySQL account used for connecting to the server. The password value is optional. If not given, mysql prompts for one. If given, there must be no space between –password= or -p and the password following it.

so you want:

$ docker exec -it my_db mysql -uroot -proot
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading