当前位置:网站首页>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.27
Create/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.27
If 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.27
Startup 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.)
边栏推荐
猜你喜欢
【图像去噪】基于matlab稀疏表示KSVD图像去噪【含Matlab源码 2016期】
加载properties文件,容器总结
sqlserver2019安装失败
Charles抓包工具学习记录
Roson的Qt之旅#106 QML在图片上方放置按钮并实现点击按钮切换图片
Arduino框架下对ESP32 NVS非易失性存储解读以及应用示例
控制bean的加载
实时目标检测新高地之#YOLOv7#更快更强的目标检测器
如何像用自来水一样使用数据库?|腾讯云数据库TDSQL-C
mysql5.7服务器The innodb_system data file 'ibdata1' must be writable导致无法启动服务器
随机推荐
SSM整合流程
“碳中和”愿景下,什么样的数据中心才是我们需要的?
《剑指Offer》刷题之打印从1到最大的n位数
【图像边缘检测】基于matlab灰度图像的积累加权边缘检测【含Matlab源码 2010期】
加载properties文件,容器总结
tmp
如何使用电子邮件营销在五个步骤中增加产品评论
推荐系统-排序层-模型:Wide&Deep
thop 使用心得
【云原生--Kubernetes】Pod重启策略
Shell运维开发基础(一)
sqlite date field plus one day
tolower函数
Evaluate: A detailed introduction to the introduction of huggingface evaluation indicator module
Roson的Qt之旅#104 QML Image控件
熊市中预言机,牛市中的战斗机,藏宝计划起飞,坐稳扶好!
数据监控平台
VR全景市场拓展技巧之“拓客宝典”
ArcEngine(四)MapControl_OnMouseDown的使用
Nanny level explains Transformer