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';

最新文章

  1. CentOS7服务器相关配置
  2. android使用library工程问题
  3. 传统企业,"哀兵必胜"的想法要不得
  4. HW5.20
  5. Authorized users only. All activity may be monitored and reported.
  6. JavaScript高级程序设计41.pdf
  7. Oracle执行计划——all_rows和first_rows(n) 优化器模式
  8. asp.net 中的错误跳转 customerrors 对html文件不起作用
  9. IDEA github的应用
  10. 1.移植uboot-分析uboot启动流程(详解)
  11. 使用Intent传递对象
  12. 【batch】命令对比两个文件夹下的文件(增删改的对比)
  13. Nikto and whatweb
  14. spring MVC 如何接收前台传入的JSON对象数组并处理
  15. 366. Fibonacci
  16. postman(五):在不同接口之间传递数据
  17. mongodb批量操作, bulk_write,
  18. 如何用R来定制个性化PPT
  19. cent7安装ffmpeg
  20. P3501 [POI2010]ANT-Antisymmetry

热门文章

  1. C++算法代码——细胞问题
  2. C++算法代码——字符串p型编码
  3. C++算法代码——众数
  4. 开发工具-scala处理json格式利器-json4s
  5. CentOS7安装ElasticSearch7.9.2
  6. Newbe.Claptrap 框架入门,第一步 —— 开发环境准备
  7. Java练习——String类练习
  8. pytorch(03)tensor的操作
  9. 关于ORACLE数据库跨库调用序列的解决办法
  10. Mysql将查询结果某个字段以逗号分隔,使用group_concat函数可以实现(配合group by使用)