当前位置:网站首页> 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 内容请搜索软件开发网以前的文章或继续浏览下面的相关文章希望大家以后多多支持软件开发网!
边栏推荐
- Project duplicate template
- Use ECs to set up an agent
- leetcode:面试题 17.24. 子矩阵最大累加和(待研究)
- npm无法安装sharp
- 关于声子和热输运计算中BORN电荷和non-analytic修正的问题
- Unified Focal loss: Generalising Dice and cross entropy-based losses to handle class imbalanced medi
- 雅思口语的具体步骤和时间安排是什么样的?
- 「小程序容器技术」,是噱头还是新风口?
- QT信号和槽
- config:invalid signature 解决办法和问题排查详解
猜你喜欢

signed、unsigned关键字

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

ACL 2022 | 序列标注的小样本NER:融合标签语义的双塔BERT模型

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

NPDP certification | how do product managers communicate across functions / teams?

让我们,从头到尾,通透网络I/O模型

Traversal of a tree in first order, middle order, and then order

Leetcode exercise - Sword finger offer 26 Substructure of tree

AdaViT——自适应选择计算结构的动态网络

CUDA exploration
随机推荐
Windows Auzre 微软的云计算产品的后台操作界面
Should novice programmers memorize code?
C three ways to realize socket data reception
【Unity】升级版·Excel数据解析,自动创建对应C#类,自动创建ScriptableObject生成类,自动序列化Asset文件
QT signal and slot
Leetcode exercise - Sword finger offer 26 Substructure of tree
Volatile keyword
[IELTS speaking] Anna's oral learning record part1
Designed for decision tree, the National University of Singapore and Tsinghua University jointly proposed a fast and safe federal learning system
POJ 1094 sorting it all out
MySQL ---- first acquaintance with MySQL
POJ 1258 Agri-Net
面试题:AOF重写机制,redis面试必问!!!
Typescript get function parameter type
雅思口语的具体步骤和时间安排是什么样的?
Mysql database basic operations DML
[leetcode] 19. Delete the penultimate node of the linked list
How big is the empty structure?
Web APIs DOM time object
On the problems of born charge and non analytical correction in phonon and heat transport calculations