当前位置:网站首页> dockermysql修改root账号密码并赋予权限
dockermysql修改root账号密码并赋予权限
2022-07-06 15:36:00 【1024问】
开始
安装vim
最近碰到程序员大离职,我并接下了别人的烂摊子。
修改docker中mysql的root账户的账号密码
所以记录一下
开始登陆CentOs linux服务器后
docker ps //查看docker镜像
进入镜像mysql镜像内部
docker exec -it 镜像id或者镜像别名 /bin/bash //进入docker内部镜像
因为docker镜像内部没有带vim命令,所以需要手动安装,也可以利用docker cp命令从宿主机中复制过去
apt-get updateapt-get install vim编辑配置文件
vim /etc/mysql/mysql.conf.d/mysqld.cnf需要加入“skip-grant-tables” 按i cv加入"skip-grant-tables" 按esc 然后:wq!

保存退出
exit # 退出容器重启mysql容器
docker restart mysql 再次进入容器
docker exec -it mysql bash登录 mysql(无需密码)
mysql -uroot更新权限
flush privileges;修改密码
alter user 'root'@'localhost' identified by '123456';退出mysql
exit注释“skip-grant-tables”
需要注释“skip-grant-tables” 按i 按esc 然后:wq!
退出容器
exit重启容器
docker restart mysql如果内部能访问,Navicat等访问不了,那么执行把mysql权限开放
错误:ERROR 1130: Host 'ip' is not allowed to connect to thisMySQL serve
原因:被连接的数据不允许使用 ip 访问,只允许是用 localhost;
进入mysql镜像
docker exec -it 镜像id或者镜像别名 /bin/bash //进入docker内部镜像登陆mysql
mysql -u root -p 输入刚刚修改的密码mysql>use mysql;mysql>select 'host' from user where user='root';mysql>update user set host = '%' where user ='root';mysql>flush privileges;mysql>select 'host' from user where user='root';如果还是不行那就是有多个root权限 更新权限
update user set password=password("root") where user="root"; 如果报已有主键id
那就删除掉localhost
到此这篇关于docker mysql修改root账号密码并赋予权限的文章就介绍到这了,更多相关docker mysql修改root 内容请搜索软件开发网以前的文章或继续浏览下面的相关文章希望大家以后多多支持软件开发网!
边栏推荐
- C three ways to realize socket data reception
- poj 1094 Sorting It All Out (拓扑排序)
- volatile关键字
- 欧洲生物信息研究所2021亮点报告发布:采用AlphaFold已预测出近1百万个蛋白质
- UVa 11732 – strcmp() Anyone?
- Machine test question 1
- Aardio - construct a multi button component with customplus library +plus
- 动作捕捉用于蛇运动分析及蛇形机器人开发
- Leetcode exercise - Sword finger offer 26 Substructure of tree
- OpenSSL: a full-featured toolkit for TLS and SSL protocols, and a general encryption library
猜你喜欢

Leetcode: interview question 17.24 Maximum cumulative sum of submatrix (to be studied)

Improving Multimodal Accuracy Through Modality Pre-training and Attention

CSDN 上传图片取消自动加水印的方法

ICLR 2022 | pre training language model based on anti self attention mechanism
![pytorch_ Yolox pruning [with code]](/img/98/31d6258635ce48ac53819d0ca12d1d.jpg)
pytorch_ Yolox pruning [with code]

金融人士必读书籍系列之六:权益投资(基于cfa考试内容大纲和框架)

Mysql 身份认证绕过漏洞(CVE-2012-2122)

Leetcode exercise - Sword finger offer 26 Substructure of tree

Balanced Multimodal Learning via On-the-fly Gradient Modulation(CVPR2022 oral)

Advantages of link local address in IPv6
随机推荐
leetcode:面试题 17.24. 子矩阵最大累加和(待研究)
Cloud native technology container knowledge points
Jafka来源分析——Processor
three. JS gorgeous bubble effect
第十九章 使用工作队列管理器(二)
memcached
Leetcode exercise - Sword finger offer 26 Substructure of tree
DR-Net: dual-rotation network with feature map enhancement for medical image segmentation
Sizeof keyword
Motion capture for snake motion analysis and snake robot development
[IELTS speaking] Anna's oral learning record part1
Should novice programmers memorize code?
Web APIs DOM time object
C# 三种方式实现Socket数据接收
2022-07-04 the high-performance database engine stonedb of MySQL is compiled and run in centos7.9
[compilation principle] LR (0) analyzer half done
case 关键字后面的值有什么要求吗?
Windows auzre background operation interface of Microsoft's cloud computing products
Pit encountered by handwritten ABA
#DAYU200体验官# 首页aito视频&Canvas绘制仪表盘(ets)