解决Docker MySQL无法被宿主机访问的问题
2024-08-28 22:48:44
1 问题描述
Docker
启动MySQL
容器后,创建一个localhost
访问的用户:
create user test@localhost identified by 'test';
但是在宿主机中无法通过该用户登录:
mycli -u test
2 原因
在Docker
中的MySQL
创建localhost
的用户只能在Docker
内部访问,而不能通过外部访问。
至于为什么能在宿主机访问root
,是因为默认存在两个root
,分别是:
root@localhost
root@%
而test
只有一个localhost
:
3 解决方案
创建test@%
或者创建test@172.17.0.1
即可:
create user test@% identified by 'test';
create user test@172.17.0.1 identified by 'test';
最新文章
- CentOS7服务器相关配置
- android使用library工程问题
- 传统企业,";哀兵必胜";的想法要不得
- HW5.20
- Authorized users only. All activity may be monitored and reported.
- JavaScript高级程序设计41.pdf
- Oracle执行计划——all_rows和first_rows(n) 优化器模式
- asp.net 中的错误跳转 customerrors 对html文件不起作用
- IDEA github的应用
- 1.移植uboot-分析uboot启动流程(详解)
- 使用Intent传递对象
- 【batch】命令对比两个文件夹下的文件(增删改的对比)
- Nikto and whatweb
- spring MVC 如何接收前台传入的JSON对象数组并处理
- 366. Fibonacci
- postman(五):在不同接口之间传递数据
- mongodb批量操作, bulk_write,
- 如何用R来定制个性化PPT
- cent7安装ffmpeg
- P3501 [POI2010]ANT-Antisymmetry
热门文章
- C++算法代码——细胞问题
- C++算法代码——字符串p型编码
- C++算法代码——众数
- 开发工具-scala处理json格式利器-json4s
- CentOS7安装ElasticSearch7.9.2
- Newbe.Claptrap 框架入门,第一步 —— 开发环境准备
- Java练习——String类练习
- pytorch(03)tensor的操作
- 关于ORACLE数据库跨库调用序列的解决办法
- Mysql将查询结果某个字段以逗号分隔,使用group_concat函数可以实现(配合group by使用)