当前位置:网站首页>Docker starts mysql
Docker starts mysql
2022-08-03 08:04:00 【Brother Mu Yao】
Download MySQL image
Docker Hub link: https://hub.docker.com/_/mysql?tab=description
mysql 8.0.27 version is used here
$ docker pull mysql:8.0.27Create/Start/Configure MySQL container
Create a mysql container named mysql-8.0.27-container based on the image mysql:8.0.27, and set the root user passwordFor ******** (remember to map port 3306 to port 3306 of the host):
$ docker run--restart=always--privileged=true--name mysql-8.0.27-container-e MYSQL_ROOT_PASSWORD=********-p 3306:3306-dmysql:8.0.27If you need to mount the data volume (/var/lib/mysql) and configuration file (/etc/mysql/conf.d) to the data of the host hard diskVolume (/home/muyao/mysql) and (/home/muyao/conf), you need to use -v to map the following parameters, only the data volume is mapped here.Complete command:
$ docker run --name mysql-8.0.27-container -e MYSQL_ROOT_PASSWORD=******** -v /home/muyao/mysql:/var/lib/mysql -p 3306:3306 -d mysql:8.0.27Startup successful!
Enter the container and run the mysql command to enable remote permissions and refresh permissions:
$ docker exec -it mysql-8.0.27-container bash$ mysql -u root -p> grant all privileges on *.* to [email protected]'%' with grant option;> flush privileges;Execute the above command.
Execution result.It can be seen that the host of root should become %, that is, all ips are allowed.
Connection Test
Use the db plugin NoSQL of vscode to test the connection, which is successful.(Stepping on the pit: The mapping of 3306 was not done at the beginning, resulting in no successful connection.) 
边栏推荐
猜你喜欢

酷雷曼上新6大功能,全景营销持续加码

xshell开启ssh端口转发,通过公网机器访问内网机器

计算机网络常见面试题总结

mysql5.7服务器The innodb_system data file 'ibdata1' must be writable导致无法启动服务器

ViewModel 记录下 +

Dapr 与 NestJs ,实战编写一个 Pub & Sub 装饰器

LeetCode 264:丑数

sqlite 日期字段加一天

服务器资源监控工具-nmon、nmon_analyser

Daily practice of PMP | Do not get lost in the exam-8.2 (including agility + multiple choice)
随机推荐
Detailed explanation of cause and effect diagram of test case design method
C语言实现树的底层遍历--超简代码
Postman will return to the interface to generate a json file to the local
wordpress: 裁剪您的图片时发生错误
PostMan使用,访问路径@RequestMapping
tmp
ceph简介
解决移动端有纵向滚动条但是不能滚动的问题
WordPress主题-B2美化通用子主题商业运营版
请求与响应:响应
postman将接口返回结果生成json文件到本地
mysql 8.0.12 安装配置方法并--设置修改密码
day12---接口和协议
[Hello World] 二分查找笔记
HCIP笔记整理 2022/7/18
【云原生--Kubernetes】Pod容器与镜像拉取策略
2022年 SQL 优化大全总结详解
ArcEngine(一)加载矢量数据
学习Glide 常用场景的写法 +
Roson的Qt之旅#103 QML之标签导航控件TabBar