当前位置:网站首页> 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 内容请搜索软件开发网以前的文章或继续浏览下面的相关文章希望大家以后多多支持软件开发网!
边栏推荐
- npm无法安装sharp
- Designed for decision tree, the National University of Singapore and Tsinghua University jointly proposed a fast and safe federal learning system
- Classification, function and usage of MySQL constraints
- On the problems of born charge and non analytical correction in phonon and heat transport calculations
- 柔性数组到底如何使用呢?
- What are the specific steps and schedule of IELTS speaking?
- Leetcode: interview question 17.24 Maximum cumulative sum of submatrix (to be studied)
- Web APIs DOM time object
- cuda 探索
- 欧洲生物信息研究所2021亮点报告发布:采用AlphaFold已预测出近1百万个蛋白质
猜你喜欢

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

leetcode:面试题 17.24. 子矩阵最大累加和(待研究)

Web APIs DOM time object

(18) LCD1602 experiment

Unified Focal loss: Generalising Dice and cross entropy-based losses to handle class imbalanced medi

动作捕捉用于蛇运动分析及蛇形机器人开发

Should novice programmers memorize code?

关于声子和热输运计算中BORN电荷和non-analytic修正的问题

Aardio - integrate variable values into a string of text through variable names

UE4蓝图学习篇(四)--流程控制ForLoop和WhileLoop
随机推荐
金融人士必读书籍系列之六:权益投资(基于cfa考试内容大纲和框架)
Cocoscreator+typescripts write an object pool by themselves
three.js绚烂的气泡效果
On the problems of born charge and non analytical correction in phonon and heat transport calculations
Windows Auzre 微软的云计算产品的后台操作界面
Dealing with the crash of QT quick project in offscreen mode
[IELTS speaking] Anna's oral learning record part1
让我们,从头到尾,通透网络I/O模型
Unified Focal loss: Generalising Dice and cross entropy-based losses to handle class imbalanced medi
Mysql database basic operations DML
Balanced Multimodal Learning via On-the-fly Gradient Modulation(CVPR2022 oral)
ICLR 2022 | pre training language model based on anti self attention mechanism
欧洲生物信息研究所2021亮点报告发布:采用AlphaFold已预测出近1百万个蛋白质
Redis 持久化机制
服务器的系统怎么选者
UDP编程
2014阿里巴巴web前实习生项目分析(1)
UE4 blueprint learning chapter (IV) -- process control forloop and whileloop
config:invalid signature 解决办法和问题排查详解
Jafka source analysis processor