当前位置:网站首页>解决在docker中部署mysql8, 密码正确但无法登陆MySQL问题
解决在docker中部署mysql8, 密码正确但无法登陆MySQL问题
2022-04-23 06:27:00 【阿兵哥哥】
1、创建并启动容器,不要设置登录密码
$ docker run -p 3306:3306 --name mysql8 --privileged=true --restart unless-stopped -v $PWD/conf:/etc/mysql/conf.d -v $PWD/logs:/logs -v $PWD/data:/var/lib/mysql -v /etc/localtime:/etc/localtime -e -d mysql:8.0.26
2、进入容器
$ docker exec -it mysql bash
3、修改配置文件
3.1 进入 /etc/mysql/conf.d 文件目录:
$ cd /etc/mysql/conf.d
3.2 创建MySQL配置文件:mysql.cnf
$ touch mysql.cnf
3.3 在 mysql.cnf 配置文件中填充以下内容
[mysqld]
# 跳过密码登录
skip-grant-tables
3.4 退出容器,重启mysql容器
$ exit
$ docker restart mysql
4、设置MySQL登录密码
4.1 重新进入MySQL容器,登录MySQL
$ docker exec -it mysql bash
$ mysql -uroot -p # 不用输入密码,直接两次回车即可
4.2 进入 mysql 表
$ use mysql
4.3 设置MySQL登录密码
$ ALTER user 'root'@'%' IDENTIFIED BY '你将要设置的密码';
4.4 刷新权限
$ flush privileges;
以上即是所有内容,接下来正常使用即可。
版权声明
本文为[阿兵哥哥]所创,转载请带上原文链接,感谢
https://blog.csdn.net/Ayue1220/article/details/120350809
边栏推荐
猜你喜欢

移动端布局(3D转换、动画)

SAP 导出Excel文件打开显示:“xxx“的文件格式和扩展名不匹配。文件可能已损坏或不安全。除非您信任其来源,否则请勿打开。是否仍要打开它?

简易随机点名抽奖(js下编写)

redis连接出错 ERR AUTH <password> called without any password configured for the default user.

Solutions to common problems in visualization (VII) solutions to drawing scale setting

Django使用mysql数据库报错解决

SAP DEBUG调试FOR IN、REDUCE等复杂的语句

利用Lambda表达式解决c#文件名排序问题(是100大还是11大的问题)

SAP PI/PO rfc2RESTful 发布rfc接口为RESTful示例(Proxy间接法)

Authorization+Token+JWT
随机推荐
SVG中年月日相关的表达式
What are the total number of all courses of Mr. Tang Xiaoyang, who is very popular in CSDN (question mark)
2022.3.14 阿里笔试
SAP 导出Excel文件打开显示:“xxx“的文件格式和扩展名不匹配。文件可能已损坏或不安全。除非您信任其来源,否则请勿打开。是否仍要打开它?
Simple random roll call lottery (written under JS)
Judge whether the beginning and end of the string contain target parameters: startswith() and endswith() methods
SAP PI/PO rfc2RESTful 发布rfc接口为RESTful示例(Proxy间接法)
canvas学习第一篇
Use of typescript dictionary
9. Common functions
异步的学习
Game assisted script development journey
简单理解==和equals,String为什么可以不用new
Reflection on the systematic design of Android audio and video caching mechanism
Django使用mysql数据库报错解决
手游性能优化
SAP PI / Po rfc2restful Publishing RFC interface as restful examples (proxy indirect)
Preliminary configuration of OpenGL super Dictionary (freeglut, glew, gltools, GLUT)
Super classic & Programming Guide (red and blue book) - Reading Notes
页面实时显示当前时间