[英]Can't login as root into MySQL container
I have a docker-compose file setup like this: 我有一个像这样的docker-compose文件设置:
version: '3'
services:
database:
image: mysql:5.6
volumes:
- dbdata:/var/lib/mysql
environment:
- "MYSQL_DATABASE=my_database_name"
- "MYSQL_USER=my_database_user"
- "MYSQL_PASSWORD=my_database_password"
- "MYSQL_ROOT_PASSWORD=my_root_password"
ports:
- "33061:3306"
volumes: dbdata: 卷:dbdata:
I'm trying to login to the mysql cli client with root user & password (by first going into the container itself): 我正在尝试使用root用户和密码登录mysql cli客户端(首先进入容器本身):
mysql -uroot -pmy_root_password
But I keep getting this error: 但我不断收到此错误:
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)
I didn't set the mysql root password env var from the very beginning. 我从一开始就没有设置mysql根密码env var。 I had to remove the created volume "dbdata" and run docker-compose up again. 我必须删除创建的卷“ dbdata”,然后再次运行docker-compose。 That fixed it. 这样就解决了。 Thanks for the help! 谢谢您的帮助!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.