docker 运行mysql问题解决
Published on Aug. 22, 2023, 12:11 p.m.
启动实例
docker run --name=mysql1 -d mysql/mysql-server:tag
初始化完成后,命令的输出将包含为 root 用户生成的随机密码;例如,使用以下命令检查密码:
docker logs mysql1 2>&1 | grep GENERATED
GENERATED ROOT PASSWORD: Axegh3kAJyDLaRuBemecis&EShOs
docker exec -it mysql1 mysql -uroot -p
#询问时,输入生成的 root 密码(请参阅上面的说明以了解如何找到它)。因为该MYSQL_ONETIME_PASSWORD选项默认为 true,所以在将mysql客户端连接到服务器后,您必须通过发出以下语句重置服务器 root 密码:
mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'password';
#替换password为您选择的密码。重置密码后,服务器就可以使用了。
https://hub.docker.com/r/mysql/mysql-server
host is not allowed to connect to this mysql server
docker exec -it mysql bash
mysql -h mysql-u yourmysqlusername -p
## change the host to blank
update mysql.user set host = ' ' where user = 'root';
flush privileges;
https://www.codegrepper.com/code-examples/sql/host+is+not+allowed+to+connect+to+this+mysql+server
Public Key Retrieval is not allowed
客户端配置
allowPublicKeyRetrieval=True