当前位置:网站首页> 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 内容请搜索软件开发网以前的文章或继续浏览下面的相关文章希望大家以后多多支持软件开发网!
边栏推荐
- 变量与“零值”的比较
- Extern keyword
- Clip +json parsing converts the sound in the video into text
- memcached
- Leetcode: interview question 17.24 Maximum cumulative sum of submatrix (to be studied)
- three. JS gorgeous bubble effect
- uniapp设置背景图效果demo(整理)
- General implementation and encapsulation of go diversified timing tasks
- ICLR 2022 | pre training language model based on anti self attention mechanism
- memcached
猜你喜欢

Balanced Multimodal Learning via On-the-fly Gradient Modulation(CVPR2022 oral)
![[leetcode] 19. Delete the penultimate node of the linked list](/img/ab/25cb6d6538ad02d78f7d64b2a2df3f.png)
[leetcode] 19. Delete the penultimate node of the linked list

案例推荐丨安擎携手伙伴,保障“智慧法院”更加高效

Leetcode exercise - Sword finger offer 26 Substructure of tree

MySQL ---- first acquaintance with MySQL

cuda 探索

UE4 blueprint learning chapter (IV) -- process control forloop and whileloop

Cocoscreator+typescripts write an object pool by themselves

专为决策树打造,新加坡国立大学&清华大学联合提出快速安全的联邦学习新系统

Matlab tips (27) grey prediction
随机推荐
Financial professionals must read book series 6: equity investment (based on the outline and framework of the CFA exam)
2022-07-05 use TPCC to conduct sub query test on stonedb
On the problems of born charge and non analytical correction in phonon and heat transport calculations
Leetcode: interview question 17.24 Maximum cumulative sum of submatrix (to be studied)
Typescript get function parameter type
UE4 blueprint learning chapter (IV) -- process control forloop and whileloop
MySQL authentication bypass vulnerability (cve-2012-2122)
General implementation and encapsulation of go diversified timing tasks
Slide the uniapp to a certain height and fix an element to the top effect demo (organize)
Matlab tips (27) grey prediction
【踩坑合辑】Attempting to deserialize object on CUDA device+buff/cache占用过高+pad_sequence
Comparison between variable and "zero value"
MySQL教程的天花板,收藏好,慢慢看
【Unity】升级版·Excel数据解析,自动创建对应C#类,自动创建ScriptableObject生成类,自动序列化Asset文件
Chapter 19 using work queue manager (2)
枚举与#define 宏的区别
室内LED显示屏应该怎么选择?这5点注意事项必须考虑在内
2014 Alibaba web pre intern project analysis (1)
volatile关键字
浅谈网络安全之文件上传