ubuntu 安装docker mysql 8.0.28
ubuntu 安装docker mysql 8.0.28
1. ubuntu 版本信息更新系统
webrx@us:~$ sudo apt update
[sudo] webrx 的密码:
命中:1 http://mirrors.aliyun.com/ubuntu focal InRelease
命中:2 http://mirrors.aliyun.com/ubuntu focal-updates InRelease
命中:3 http://mirrors.aliyun.com/ubuntu focal-backports InRelease
命中:4 http://mirrors.aliyun.com/ubuntu focal-security InRelease
命中:5 http://apt.postgresql.org/pub/repos/apt focal-pgdg InRelease
正在读取软件包列表... 完成
正在分析软件包的依赖关系树
正在读取状态信息... 完成
所有软件包均为最新。webrx@us:~$ sudo apt list --upgradeable
正在列表... 完成webrx@us:~$ sudo apt upgrade -y
正在读取软件包列表... 完成
正在分析软件包的依赖关系树
正在读取状态信息... 完成
正在计算更新... 完成
下列软件包是自动安装的并且现在不需要了:linux-headers-5.4.0-96 linux-headers-5.4.0-96-generic linux-image-5.4.0-96-genericlinux-modules-5.4.0-96-generic linux-modules-extra-5.4.0-96-generic
使用'sudo apt autoremove'来卸载它(它们)。
升级了 0 个软件包,新安装了 0 个软件包,要卸载 0 个软件包,有 0 个软件包未被升级。webrx@us:~$ cat /etc/os-release
NAME="Ubuntu"
VERSION="20.04.4 LTS (Focal Fossa)"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 20.04.4 LTS"
VERSION_ID="20.04"
HOME_URL="https://www.ubuntu.com/"
SUPPORT_URL="https://help.ubuntu.com/"
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
VERSION_CODENAME=focal
UBUNTU_CODENAME=focalwebrx@us:~$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 20.04.4 LTS
Release: 20.04
Codename: focal
webrx@us:~$
2. 安装docker
curl -fsSL https://get.docker.com | bash -s docker --mirror Aliyun
webrx@us:~$ curl -fsSL https://get.docker.com | bash -s docker --mirror Aliyun
# Executing docker install script, commit: 93d2499759296ac1f9c510605fef85052a2c32be
+ sudo -E sh -c 'apt-get update -qq >/dev/null'
+ sudo -E sh -c 'DEBIAN_FRONTEND=noninteractive apt-get install -y -qq apt-transport-https ca-certificates curl >/dev/null'
+ sudo -E sh -c 'curl -fsSL "https://mirrors.aliyun.com/docker-ce/linux/ubuntu/gpg" | gpg --dearmor --yes -o /usr/share/keyrings/docker-archive-keyring.gpg'
+ sudo -E sh -c 'echo "deb [arch=amd64 signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://mirrors.aliyun.com/docker-ce/linux/ubuntu focal stable" > /etc/apt/sources.list.d/docker.list'
+ sudo -E sh -c 'apt-get update -qq >/dev/null'
+ sudo -E sh -c 'DEBIAN_FRONTEND=noninteractive apt-get install -y -qq --no-install-recommends docker-ce-cli docker-scan-plugin docker-ce >/dev/null'
+ version_gte 20.10
+ '[' -z '' ']'
+ return 0
+ sudo -E sh -c 'DEBIAN_FRONTEND=noninteractive apt-get install -y -qq docker-ce-rootless-extras >/dev/null'
+ sudo -E sh -c 'docker version'
Client: Docker Engine - CommunityVersion: 20.10.12API version: 1.41Go version: go1.16.12Git commit: e91ed57Built: Mon Dec 13 11:45:33 2021OS/Arch: linux/amd64Context: defaultExperimental: trueServer: Docker Engine - CommunityEngine:Version: 20.10.12API version: 1.41 (minimum version 1.12)Go version: go1.16.12Git commit: 459d0dfBuilt: Mon Dec 13 11:43:42 2021OS/Arch: linux/amd64Experimental: falsecontainerd:Version: 1.4.12GitCommit: 7b11cfaabd73bb80907dd23182b9347b4245eb5drunc:Version: 1.0.2GitCommit: v1.0.2-0-g52b36a2docker-init:Version: 0.19.0GitCommit: de40ad0================================================================================To run Docker as a non-privileged user, consider setting up the
Docker daemon in rootless mode for your user:dockerd-rootless-setuptool.sh installVisit https://docs.docker.com/go/rootless/ to learn about rootless mode.To run the Docker daemon as a fully privileged service, but granting non-root
users access, refer to https://docs.docker.com/go/daemon-access/WARNING: Access to the remote API on a privileged Docker daemon is equivalentto root access on the host. Refer to the 'Docker daemon attack surface'documentation for details: https://docs.docker.com/go/attack-surface/================================================================================webrx@us:~$
webrx@us:~$ sudo systemctl status docker
● docker.service - Docker Application Container EngineLoaded: loaded (/lib/systemd/system/docker.service; enabled; vendor preset: enabled)Active: active (running) since Sat 2022-02-19 13:24:36 CST; 11min ago
TriggeredBy: ● docker.socketDocs: https://docs.docker.comMain PID: 51456 (dockerd)Tasks: 8Memory: 28.1MCGroup: /system.slice/docker.service└─51456 /usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock2月 19 13:24:32 us dockerd[51456]: time="2022-02-19T13:24:32.093608663+08:00" level=warning msg="Your kernel does not support CPU realtime scheduler"
2月 19 13:24:32 us dockerd[51456]: time="2022-02-19T13:24:32.093620361+08:00" level=warning msg="Your kernel does not support cgroup blkio weight"
2月 19 13:24:32 us dockerd[51456]: time="2022-02-19T13:24:32.093626284+08:00" level=warning msg="Your kernel does not support cgroup blkio weight_device"
2月 19 13:24:32 us dockerd[51456]: time="2022-02-19T13:24:32.093857078+08:00" level=info msg="Loading containers: start."
2月 19 13:24:36 us dockerd[51456]: time="2022-02-19T13:24:36.112478891+08:00" level=info msg="Default bridge (docker0) is assigned with an IP address 172.17.0.0/16. >
2月 19 13:24:36 us dockerd[51456]: time="2022-02-19T13:24:36.213898321+08:00" level=info msg="Loading containers: done."
2月 19 13:24:36 us dockerd[51456]: time="2022-02-19T13:24:36.262993132+08:00" level=info msg="Docker daemon" commit=459d0df graphdriver(s)=overlay2 version=20.10.12
2月 19 13:24:36 us dockerd[51456]: time="2022-02-19T13:24:36.263529179+08:00" level=info msg="Daemon has completed initialization"
2月 19 13:24:36 us systemd[1]: Started Docker Application Container Engine.
2月 19 13:24:36 us dockerd[51456]: time="2022-02-19T13:24:36.314628027+08:00" level=info msg="API listen on /run/docker.sock"webrx@us:~$ sudo service --status-all[ + ] apparmor[ + ] apport[ + ] atd[ - ] console-setup.sh[ + ] cron[ - ] cryptdisks[ - ] cryptdisks-early[ + ] dbus[ + ] docker[ - ] grub-common[ - ] hwclock.sh[ + ] irqbalance[ - ] iscsid[ - ] keyboard-setup.sh[ + ] kmod[ - ] lvm2[ - ] lvm2-lvmpolld[ + ] multipath-tools[ - ] open-iscsi[ + ] open-vm-tools[ - ] plymouth[ - ] plymouth-log[ + ] postgresql[ + ] procps[ - ] rsync[ + ] rsyslog[ - ] screen-cleanup[ + ] ssh[ + ] sysstat[ + ] udev[ + ] ufw[ + ] unattended-upgrades[ + ] uuiddwebrx@us:~$ sudo service docker status
● docker.service - Docker Application Container EngineLoaded: loaded (/lib/systemd/system/docker.service; enabled; vendor preset: enabled)Active: active (running) since Sat 2022-02-19 13:24:36 CST; 12min ago
TriggeredBy: ● docker.socketDocs: https://docs.docker.comMain PID: 51456 (dockerd)Tasks: 8Memory: 28.1MCGroup: /system.slice/docker.service└─51456 /usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock2月 19 13:24:32 us dockerd[51456]: time="2022-02-19T13:24:32.093608663+08:00" level=warning msg="Your kernel does not support CPU realtime scheduler"
2月 19 13:24:32 us dockerd[51456]: time="2022-02-19T13:24:32.093620361+08:00" level=warning msg="Your kernel does not support cgroup blkio weight"
2月 19 13:24:32 us dockerd[51456]: time="2022-02-19T13:24:32.093626284+08:00" level=warning msg="Your kernel does not support cgroup blkio weight_device"
2月 19 13:24:32 us dockerd[51456]: time="2022-02-19T13:24:32.093857078+08:00" level=info msg="Loading containers: start."
2月 19 13:24:36 us dockerd[51456]: time="2022-02-19T13:24:36.112478891+08:00" level=info msg="Default bridge (docker0) is assigned with an IP address 172.17.0.0/16. >
2月 19 13:24:36 us dockerd[51456]: time="2022-02-19T13:24:36.213898321+08:00" level=info msg="Loading containers: done."
2月 19 13:24:36 us dockerd[51456]: time="2022-02-19T13:24:36.262993132+08:00" level=info msg="Docker daemon" commit=459d0df graphdriver(s)=overlay2 version=20.10.12
2月 19 13:24:36 us dockerd[51456]: time="2022-02-19T13:24:36.263529179+08:00" level=info msg="Daemon has completed initialization"
2月 19 13:24:36 us systemd[1]: Started Docker Application Container Engine.
2月 19 13:24:36 us dockerd[51456]: time="2022-02-19T13:24:36.314628027+08:00" level=info msg="API listen on /run/docker.sock"
webrx@us:~$
3. 配置docker
3.1 免sudo 执行docker命令
webrx@us:~$ sudo adduser $USER docker
[sudo] webrx 的密码:
正在添加用户"webrx"到"docker"组...
正在将用户“webrx”加入到“docker”组中
完成。
webrx@us:~$ sudo adduser webrx docker
用户"webrx"已经属于"docker"组。
webrx@us:~$ docker version
Client: Docker Engine - CommunityVersion: 20.10.12API version: 1.41Go version: go1.16.12Git commit: e91ed57Built: Mon Dec 13 11:45:33 2021OS/Arch: linux/amd64Context: defaultExperimental: true
Got permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock: Get "http://%2Fvar%2Frun%2Fdocker.sock/v1.24/version": dial unix /var/run/docker.sock: connect: permission deniedwebrx@us:~$ docker --version
Docker version 20.10.12, build e91ed57
3.2 Docker 镜像加速
国内从 DockerHub 拉取镜像有时会遇到困难,此时可以配置镜像加速器。Docker 官方和国内很多云服务商都提供了国内加速器服务,例如:
科大镜像:https://docker.mirrors.ustc.edu.cn/
网易:https://hub-mirror.c.163.com/
阿里云:https://<你的ID>.mirror.aliyuncs.com
七牛云加速器:https://reg-mirror.qiniu.com
Docker中国区官方镜像https://registry.docker-cn.com
网易http://hub-mirror.c.163.com
ustc 中国科技大学https://docker.mirrors.ustc.edu.cn
#创建或修改 /etc/docker/daemon.json 文件,修改为如下形式
webrx@us:~$ sudo vim /etc/docker/daemon.json 内容如下 按esc 输入:wq保存文件
{"registry-mirrors": ["https://registry.docker-cn.com","http://hub-mirror.c.163.com","https://docker.mirrors.ustc.edu.cn"]
}
webrx@us:~$ docker info
Client:Context: defaultDebug Mode: falsePlugins:app: Docker App (Docker Inc., v0.9.1-beta3)buildx: Docker Buildx (Docker Inc., v0.7.1-docker)scan: Docker Scan (Docker Inc., v0.12.0)Server:Containers: 0Running: 0Paused: 0Stopped: 0Images: 0Server Version: 20.10.12Storage Driver: overlay2Backing Filesystem: extfsSupports d_type: trueNative Overlay Diff: trueuserxattr: falseLogging Driver: json-fileCgroup Driver: cgroupfsCgroup Version: 1Plugins:Volume: localNetwork: bridge host ipvlan macvlan null overlayLog: awslogs fluentd gcplogs gelf journald json-file local logentries splunk syslogSwarm: inactiveRuntimes: io.containerd.runc.v2 io.containerd.runtime.v1.linux runcDefault Runtime: runcInit Binary: docker-initcontainerd version: 7b11cfaabd73bb80907dd23182b9347b4245eb5drunc version: v1.0.2-0-g52b36a2init version: de40ad0Security Options:apparmorseccompProfile: defaultKernel Version: 5.4.0-99-genericOperating System: Ubuntu 20.04.4 LTSOSType: linuxArchitecture: x86_64CPUs: 2Total Memory: 3.81GiBName: usID: M744:MAFZ:O5ZB:RZZ6:X5SU:RWUN:MWLL:CNUR:ZPU3:XSDR:UWBD:GQOFDocker Root Dir: /var/lib/dockerDebug Mode: falseRegistry: https://index.docker.io/v1/Labels:Experimental: falseInsecure Registries:127.0.0.0/8Registry Mirrors:https://registry.docker-cn.com/http://hub-mirror.c.163.com/https://docker.mirrors.ustc.edu.cn/Live Restore Enabled: falseWARNING: No swap limit support
查看加速是否生效
4. docker 安装mysql 8.0.28
4.1 docker images
webrx@us:~$ docker images
REPOSITORY TAG IMAGE ID CREATED SIZEwebrx@us:~$ docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
mysql latest 17b062d639f4 29 hours ago 519MB
4.2 docker pull
webrx@us:~$ docker pull mysql
Using default tag: latest
latest: Pulling from library/mysql
6552179c3509: Pull complete
d69aa66e4482: Pull complete
3b19465b002b: Pull complete
7b0d0cfe99a1: Pull complete
9ccd5a5c8987: Pull complete
2dab00d7d232: Pull complete
5d726bac08ea: Pull complete
11bb049c7b94: Pull complete
7fcdd679c458: Pull complete
11585aaf4aad: Pull complete
5b5dc265cb1d: Pull complete
fd400d64ffec: Pull complete
Digest: sha256:e3358f55ea2b0cd432685d7e3c79a33a85c7a359b35fa87fc4993514b9573446
Status: Downloaded newer image for mysql:latest
docker.io/library/mysql:latest
4.3 docker inspect mysql
查看镜像文件的相关信息
webrx@us:~$ docker inspect mysql
[{"Id": "sha256:17b062d639f4a10bf2439de7204856ea552a68fa5d7cd2f28c16066e340358c1","RepoTags": ["mysql:latest"],"RepoDigests": ["mysql@sha256:e3358f55ea2b0cd432685d7e3c79a33a85c7a359b35fa87fc4993514b9573446"],"Parent": "","Comment": "","Created": "2022-02-18T01:23:30.594541792Z","Container": "f27f850d7ce7da5c1407f71bf26deba6a66d30b95fa6796dd9f39eda199e553b","ContainerConfig": {"Hostname": "f27f850d7ce7","Domainname": "","User": "","AttachStdin": false,"AttachStdout": false,"AttachStderr": false,"ExposedPorts": {"3306/tcp": {},"33060/tcp": {}},"Tty": false,"OpenStdin": false,"StdinOnce": false,"Env": ["PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin","GOSU_VERSION=1.14","MYSQL_MAJOR=8.0","MYSQL_VERSION=8.0.28-1debian10"],"Cmd": ["/bin/sh","-c","#(nop) ","CMD [\"mysqld\"]"],"Image": "sha256:a19801229fca3ba3ecf3f792da774f8e30653018e673cf79fc8d97b3a0beeff1","Volumes": {"/var/lib/mysql": {}},"WorkingDir": "","Entrypoint": ["docker-entrypoint.sh"],"OnBuild": null,"Labels": {}},"DockerVersion": "20.10.7","Author": "","Config": {"Hostname": "","Domainname": "","User": "","AttachStdin": false,"AttachStdout": false,"AttachStderr": false,"ExposedPorts": {"3306/tcp": {},"33060/tcp": {}},"Tty": false,"OpenStdin": false,"StdinOnce": false,"Env": ["PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin","GOSU_VERSION=1.14","MYSQL_MAJOR=8.0","MYSQL_VERSION=8.0.28-1debian10"],"Cmd": ["mysqld"],"Image": "sha256:a19801229fca3ba3ecf3f792da774f8e30653018e673cf79fc8d97b3a0beeff1","Volumes": {"/var/lib/mysql": {}},"WorkingDir": "","Entrypoint": ["docker-entrypoint.sh"],"OnBuild": null,"Labels": null},"Architecture": "amd64","Os": "linux","Size": 519356694,"VirtualSize": 519356694,"GraphDriver": {"Data": {"LowerDir": "/var/lib/docker/overlay2/59511d90c6a21404d0c3176e47de05d56e118d3f2dfcc926574d9bdadb20ffe1/diff:/var/lib/docker/overlay2/596ba5cd557a63f0a9e1856b2ef2975880ae9cd0bd1fb42af65221e9d0ec3372/diff:/var/lib/docker/overlay2/3142de1b074378b2ff042e1a1386fef09e0154115b0352beba8334ab7df6440c/diff:/var/lib/docker/overlay2/7977c30651bce447efec27f203cd5f05b629720713e512dfba9be1da43576317/diff:/var/lib/docker/overlay2/f4e747f7cc4117ca424b57cc67509ef82d7b70f5708dc1f802ca794216065259/diff:/var/lib/docker/overlay2/8b8f8f2f73675d870a2e54fb9ec9f3d7893158d7b2cc8b74398ba337fcbab36e/diff:/var/lib/docker/overlay2/717f0fc6b155b1fddb15e56bc78fee04d2676d1c6e9fd1e6ef3ec72b965fdef9/diff:/var/lib/docker/overlay2/dd92e17fa027a68687fcab03245416e92c417c093ae4962fccd8050846860974/diff:/var/lib/docker/overlay2/eac50df9a1bac9e8dc9dcbf9c69ec449042d3e1051b857f83c77f8abe6d7abcb/diff:/var/lib/docker/overlay2/9440a291c7b2982a08aacc741ee0f089e2d54319a44ce25af4ba8eb3db8cee17/diff:/var/lib/docker/overlay2/9f20860d5ba2968643cf5473875a426298fa345f4e4a4983fc6392052da58927/diff","MergedDir": "/var/lib/docker/overlay2/78ced0baf6f81213504f802008c350f0f8435a17c2a2a3899f52e65f4876ec8b/merged","UpperDir": "/var/lib/docker/overlay2/78ced0baf6f81213504f802008c350f0f8435a17c2a2a3899f52e65f4876ec8b/diff","WorkDir": "/var/lib/docker/overlay2/78ced0baf6f81213504f802008c350f0f8435a17c2a2a3899f52e65f4876ec8b/work"},"Name": "overlay2"},"RootFS": {"Type": "layers","Layers": ["sha256:f18b02b14138b6f9808f9843cc645e2edd64b02ca1c87e671355f56d1b4b5ec6","sha256:cec83252c1b64341aecd93049e5740a244bd121d272997ead7306c83eb88eee6","sha256:88bee9dc2401e913ce28646de90910227350c816bd10cc3d3ec6ef71b9dd68be","sha256:ced951e096b9f3bd8685220540ed157704c1f09a7224ecccc1a0748cdbb858e9","sha256:0147a12f509faefda39861075d14ed7604cac10fc32117868dc51792a6020dac","sha256:b2bde2ef1f635f1f2c63e3da55f1c967c29b4cd01e64d2aaf62fbdcb870baac7","sha256:a6aad77fe0357f701634d0939b3b728b23d02b735b554475952a9874b4f8c0f9","sha256:da90c9132777439e7f17dfded48f3fe9625e0237e7e13cf4dcaa1a9604562a2e","sha256:8c9559afb9b9645e595aa035727f805504c384ad67621cb7390cfce9b4a9e119","sha256:73754ed5eff30fc2edea24373d77d049184dd93d8563e6cde863f40dc60c5a26","sha256:3d0737b0f80c06c6e5d071c1c484c275b95b38a05865e0047d1d59874485e505","sha256:ab1580f17d51ae77719c561b22c2d269dd806d9f0b36cf1f20d43c877a1efd1e"]},"Metadata": {"LastTagTime": "0001-01-01T00:00:00Z"}}
]
webrx@us:~$
4.4 建立mysql容器
hub.docker.com官方查看使用帮助
4.4.1 建立容器1
webrx@us:~$ docker run -itd --name m8 -P -e MYSQL_ROOT_PASSWORD=root mysql
4d850a20782ea109c994fe301d569ea6ef5be2c4cb2b02672ea03b6f94af583c
webrx@us:~$ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
4d850a20782e mysql "docker-entrypoint.s…" 6 seconds ago Up 5 seconds 0.0.0.0:49154->3306/tcp, :::49154->3306/tcp, 0.0.0.0:49153->33060/tcp, :::49153->33060/tcp m8
webrx@us:~$ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
4d850a20782e mysql "docker-entrypoint.s…" About a minute ago Up About a minute 0.0.0.0:49154->3306/tcp, :::49154->3306/tcp, 0.0.0.0:49153->33060/tcp, :::49153->33060/tcp m8
webrx@us:~$
测试容器 ubuntu 192.168.0.68
C:\>mysql -h192.168.0.68 -uroot -p -P49154
Enter password: ****
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 8
Server version: 8.0.28 MySQL Community Server - GPLCopyright (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> select versioin();
ERROR 1046 (3D000): No database selected
mysql> select version();
+-----------+
| version() |
+-----------+
| 8.0.28 |
+-----------+
1 row in set (0.00 sec)mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| sys |
+--------------------+
4 rows in set (0.01 sec)mysql> select now();
+---------------------+
| now() |
+---------------------+
| 2022-02-19 07:09:42 |
+---------------------+
1 row in set (0.00 sec)mysql> show variables like 'char%';
+--------------------------+--------------------------------+
| Variable_name | Value |
+--------------------------+--------------------------------+
| character_set_client | utf8mb3 |
| character_set_connection | utf8mb3 |
| character_set_database | utf8mb4 |
| character_set_filesystem | binary |
| character_set_results | utf8mb3 |
| character_set_server | utf8mb4 |
| character_set_system | utf8mb3 |
| character_sets_dir | /usr/share/mysql-8.0/charsets/ |
+--------------------------+--------------------------------+
8 rows in set (0.01 sec)
4.4.2 建立容器2
webrx@us:~$ docker run -itd --name m3308 -p 3308:3306 -e MYSQL_ROOT_PASSWORD=root -e TZ="Asia/Shanghai" mysql
56552fa965101f1b0dfc35b2c88de9a1c7eb6843a3bc586e7ab748d00d72ef7b
webrx@us:~$ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
56552fa96510 mysql "docker-entrypoint.s…" 3 seconds ago Up 2 seconds 33060/tcp, 0.0.0.0:3308->3306/tcp, :::3308->3306/tcp m3308
4d850a20782e mysql "docker-entrypoint.s…" 8 minutes ago Up 8 minutes 0.0.0.0:49154->3306/tcp, :::49154->3306/tcp, 0.0.0.0:49153->33060/tcp, :::49153->33060/tcp m8
webrx@us:~$
C:\>mysql -h192.168.0.68 -uroot -p -P3308
Enter password: ****
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 8
Server version: 8.0.28 MySQL Community Server - GPLCopyright (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> select now();
+---------------------+
| now() |
+---------------------+
| 2022-02-19 15:15:17 |
+---------------------+
1 row in set (0.00 sec)
4.4.3 常用参数
1. docker run -itd --name m8 -P -e MYSQL_ROOT_PASSWORD=root mysql2. docker run -itd --name m3308 -p 3308:3306 -e MYSQL_ROOT_PASSWORD=root -e TZ="Asia/Shanghai" mysql-P 随机端口号 41954:3306
-p 3308:3306
-itd
--name m330
-e MYSQL_ROOT_PASSWORD=root
-e TZ="Asia/Shanghai" #时区
--restart=always #容器随docker自动启动3. docker run -it --rm mysql mysql -h192.168.0.68 -uroot -P3308 -p
4.4.4 建立自删除容器3
webrx@us:~$ docker run -it --rm mysql mysql -h192.168.0.68 -uroot -P3308 -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 9
Server version: 8.0.28 MySQL Community Server - GPLCopyright (c) 2000, 2022, 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> select version();
+-----------+
| version() |
+-----------+
| 8.0.28 |
+-----------+
1 row in set (0.00 sec)mysql> select now();
+---------------------+
| now() |
+---------------------+
| 2022-02-19 15:22:36 |
+---------------------+
1 row in set (0.00 sec)mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| sys |
+--------------------+
4 rows in set (0.00 sec)mysql> create databse db;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'databse db' at line 1
mysql> create database db;
Query OK, 1 row affected (0.01 sec)mysql> use db;
Database changed
mysql> create table t(id int,name varchar(30));
Query OK, 0 rows affected (0.01 sec)mysql> insert into t set id=10,name='lisi';
Query OK, 1 row affected (0.01 sec)mysql> insert into t set id=20,name='wangwu';
Query OK, 1 row affected (0.01 sec)mysql> select * from t;
+------+--------+
| id | name |
+------+--------+
| 10 | lisi |
| 20 | wangwu |
+------+--------+
2 rows in set (0.00 sec)mysql> select * from t;
+------+--------+
| id | name |
+------+--------+
| 10 | lisi |
| 20 | wangwu |
| 55 | ?? |
+------+--------+
3 rows in set (0.00 sec)mysql>
webrx@us:~$ docker ps -aq
56552fa96510
4d850a20782e
webrx@us:~$ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
56552fa96510 mysql "docker-entrypoint.s…" 11 minutes ago Up 11 minutes 33060/tcp, 0.0.0.0:3308->3306/tcp, :::3308->3306/tcp m3308
4d850a20782e mysql "docker-entrypoint.s…" 19 minutes ago Up 19 minutes 0.0.0.0:49154->3306/tcp, :::49154->3306/tcp, 0.0.0.0:49153->33060/tcp, :::49153->33060/tcp m8
webrx@us:~$
4.5 删除容器
webrx@us:~$ docker rm --helpUsage: docker rm [OPTIONS] CONTAINER [CONTAINER...]Remove one or more containersOptions:-f, --force Force the removal of a running container (uses SIGKILL)-l, --link Remove the specified link-v, --volumes Remove anonymous volumes associated with the containerwebrx@us:~$ docker rm $(docker ps -aq) -f #强制删除所有容器,包括正在运行的容器
56552fa96510
4d850a20782ewebrx@us:~$ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMESwebrx@us:~$ docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
ubuntu 安装docker mysql 8.0.28相关推荐
- mysql 8.0.28版本安装配置方法图文教程
mysql 8.0.28版本安装配置方法图文教程 从 Mysql 官网下载 mysql 下载完成后直接双击进行安装,打开后的页面如下所示: 选择自定义custom,接着下一步 将MySQL Serve ...
- 国产麒麟系统KylinOS Server V10 SP2安装MySQL 8.0.28—RPM包安装
最近工作重点转向信创领域后就开始研究国产化操作系统对各种数据库的适配方案,期间发现一些很有价值的内容,特意整理成文章分享出来. 此文档讲述如何在国产麒麟操作系统KylinOS Server V10 S ...
- Ubuntu安装Docker引擎和支持HTTPS的docker-registry服务
原创作品,允许转载,转载时请务必以超链接形式标明文章 原始出处 .作者信息和本声明.否则将追究法律责任.http://dgd2010.blog.51cto.com/1539422/1729858 虽然 ...
- ubuntu 安装docker
Ubuntu 安装 Docker CE 警告:切勿在没有配置 Docker APT 源的情况下直接使用 apt 命令安装 Docker. 准备工作 系统要求 Docker CE 支持以下版本的 Ubu ...
- ubuntu 安装docker私服
WIN10 VM 安装ubuntu 安装docker registry 安装docker 客服端 安装docker WEBUI 安装docker registry docker 镜像在实际开发中,往往 ...
- Ubuntu 安装 Docker CE及配置国内加速
Ubuntu 安装 Docker CE 警告:切勿在没有配置 Docker APT 源的情况下直接使用 apt 命令安装 Docker. 准备工作 系统要求 Docker CE 支持以下版本的 Ubu ...
- 安装最新mysql 8.0.22在windows10
在windows10下安装最新mysql 8.0.22 若重装 mysql可以看简捷版https://blog.csdn.net/ahmcwt/article/details/109859805 一. ...
- 安装数据库MySQL 8.0.20.0 详细过程 小白安装
安装数据库MySQL 8.0.20.0 详细过程 小白安装 耐心等待 复制完回到这里来 我们输入 net start 我们输入 net start 当然 我们也可以关闭数据库 命令如下 net sto ...
- mysql 8.0.28安装教程(超简单)
背景:目前在网络上的mysql安装教程,针对的mysql版本较老,或者安装教程使用的mysql软件多是解压版本,解压过程简单,但是后续配置相对比较麻烦,并且可能因为缺少某些C++依赖包而导致程序无法正 ...
最新文章
- 烂泥:mysql5.5数据库cmake源码编译安装
- DRF (Django REST framework) 框架介绍
- Python3网络爬虫(四): 登录
- java安全权限配置_使用Spring安全表达式控制系统功能访问权限问题
- python RSA加密、解密、签名
- c++string函数(一)——find、rfind详细用法
- python函数定义及调用-python函数声明和调用定义及原理详解
- Scratch 3.0 指令大全-“运动”类别的详细介绍②
- fh 幅频特性曲线怎么画fl_放大电路幅频特性曲线的测试方法.PPT
- 当前安装包签名出现异常_安卓系统手机安装应用出现应用签名异常或-22错误(联网验证失败)的应对方法...
- cl.exe nmake.exe
- css字体居中(css字体居中对齐)
- turtle库绘图:绘制QQ所有表情
- Android iText向pdf模板插入数据和图片
- win10自带录屏怎么用?两种方法快来get
- 学计算机i5九代,九代i5和九代i7区别
- 微博数据采集API 附咨询公司微博大数据分析实例
- anaconda prompt 终端运行py文件
- 项目经理通过甘特图编制项目计划的方法
- 大学生安全教育网课答案