Skip to content
On this page

设置国内镜像源

  1. 启动 docker desktop

  2. 右击托盘图标选择 settings,选择 Docker Engine 菜单,

增加国内镜像地址,增加私有仓库地址

json
{
  "builder": {
    "gc": {
      "defaultKeepStorage": "20GB",
      "enabled": true
    }
  },
  "experimental": false,
  "features": {
    "buildkit": true
  },
  "registry-mirrors": [
    "http://hub-mirror.c.163.com",
    "https://docker.mirrors.ustc.edu.cn"
  ]
}

安装 mysql 服务

windows 的命令行中执行

shell
docker run -itd --name mysql -e MYSQL_ROOT_PASSWORD=密码1 -p 3306:3306 mysql

-p 把本电脑的 3306 端口和容器 mysql 的 3306 端口绑定,从而方便在本电脑上访问容器内的数据库

  • 创建新用户
shell
docker exec -it mysql /bin/bash   # 关联容器
  mysql -uroot -p密码1               # 登录容器的mysql

  create user '[your name]'@'localhost' identified by '[your pass]'  # 创建新用户
  • 修改权限

给用户赋予所有权限

shell
grant all privileges on *.* to '[your name]'@'%' with grant option;
  • 修改连接方式

mysql 8.0 默认使用 caching_sha2_password 身份验证机制;客户端不支持新的加密方式。

shell
ALTER USER '[your name]'@'%' IDENTIFIED WITH mysql_native_password BY '[your pass]';

常见错误

unexpected wsl error not connected your domain

  • 检查是否开启虚拟化服务 控制面板 -> 启动或更新 windows 服务 勾选 虚拟机平台、适用于 linux 的 windows 子系统 然后重启

  • 执行下面命令并重启

shell
netsh winsock reset