当前位置:网站首页>基于docker安装MySQL
基于docker安装MySQL
2022-07-28 09:57:00 【不爱说话的小张】
目录
1. 查看要安装的MySQL
# docker search mysql
dockerhub地址Docker Hub
2. 拉取MySQL镜像
# docker pull mysql
[[email protected] ~]# docker pull mysql Using default tag: latest latest: Pulling from library/mysql Digest: sha256:6d7d4524463fe6e2b893ffc2b89543c81dec7ef82fb2020a1b27606666464d87 Status: Image is up to date for mysql:latest docker.io/library/mysql:latest [[email protected] ~]#
3. 根据镜像创建mysql容器
docker run -itd --name mysql --restart always --privileged=true \ -v /daya/mysql/conf:/etc/mysql/conf.d \
-v /data/mysql/data:/var/lib/mysql \
-v /data/mysql/logs:/var/log \
-p 3306:3306 -e MYSQL_ROOT_PASSWORD=admin \
mysql --character-set-server=utf8 --collation-server=utf8_general_ci
[[email protected] ~]# docker run -itd --name mysql --restart always --privileged=true \
-v /daya/mysql/conf:/etc/mysql/conf.d \
-v /data/mysql/data:/var/lib/mysql \
-v /data/mysql/logs:/var/log \
-p 3306:3306 -e MYSQL_ROOT_PASSWORD=admin \
mysql --character-set-server=utf8 --collation-server=utf8_general_ci
6ffd0507b1b1dcec967ccb7df4fbb077021c2dea9857e5e122fdc0df6d36a0e5
[[email protected] ~]# -e MYSQL_ROOT_PASSWORD=admin 设置数据库密码
--character-set-server=utf8 --collation-server=utf8_general_ci 设置编码格式
4. 进入容器内部并测试mysql是否创建成功
# j进入容器内部
docker exec -it mysql /bin/bash
# 连接mysql
mysql -uroot -p
[[email protected] ~]# docker exec -it mysql /bin/bash
[email protected]:/# mysql -uroot -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 148
Server version: 8.0.27 MySQL Community Server - GPL
Copyright (c) 2000, 2021, Oracle and/or its affiliates.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| sys |
+--------------------+
4 rows in set (0.00 sec)
mysql> 也可以使用Navicat 工具进行连接
边栏推荐
- Set of bus related concepts
- LSA and optimization of OSPF
- Experiment 4 uses fdisk to manage hard disk
- In php7?? And?: Differences between
- It can traverse all files and subfolders under a folder
- Which strings will be resolved to null by fastjason?
- OSPF的拓展配置,选路原则,防环及重发布
- Read Plato farm's eplato and the reason for its high premium
- Flink - checkpoint Failure reason: Not all required tasks are currently running
- CGAL编译错误
猜你喜欢

Redis interview questions must be known and learned

Extreme deflation and perpetual motion machine model will promote the outbreak of platofarm

2022 uni app parsing token standard - use jsrsasign - climb the pit

In retaliation for the dismissal of the company, I changed all code comments of the project!

Being on duty less than 8 hours a day and being dismissed? Tencent's former employees recovered 13million overtime pay, etc., and the court won a compensation of 90000 in the final judgment

【JZOF】14剪绳子
![[ESP32][esp-idf][LVGL7.9] 使用oled iic编译失败](/img/16/e5aa43df6ef9bdbc173fa547c85559.png)
[ESP32][esp-idf][LVGL7.9] 使用oled iic编译失败

关于软考高级要不要报班学习

arthas使用教程

高温天气筑牢安全生产防线,广州海珠区开展加油站应急演练
随机推荐
[openharmony] [rk2206] build openharmony compiler (2)
广州地铁14号线新市墟站开建,白云区居民即将开启双线换乘模式!
pkg打包node工程
第四步-用户开发环境设置
[OpenHarmony] [RK2206] 构建OpenHarmony编译器 (二)
Consul
Several innovative economic models of platofarm have inspired the current metacosmic market
j s的数组方法,循环
The blind box of super primitive series will be launched soon, and platofarm will enable more rights and interests
Installing MySQL for Linux operating system (centos7)
ASP.NET Core 6框架揭秘实例演示[29]:搭建文件服务器
matlab特征点提取--记录自用
Include and require include_ Once and require_ Once difference
Experiment 4 uses fdisk to manage hard disk
_HUGE and __IMP__HUGE in “math.h“
工业品MRO采购网站有哪些优势?一文带你读懂
ADVANCE.AI出海指南助力企业出海印尼,掌握东南亚市场半边天
ES(8.1)认证题目
小黑重新站起来看leetcode:653. 两数之和 IV - 输入 BST
Seektiger eco pass STI new progress, log in to ZB on April 14