美文网首页SpringCloud
Docker安装MySql8.0

Docker安装MySql8.0

作者: 葉糖糖 | 来源:发表于2023-05-10 22:13 被阅读0次

使用Docker安装MySql8.0效率很高。

一、下载镜像
1、 docker pull mysql8.0

二、创建文件夹

mkdir -p /usr/local/docker/mysql/conf
mkdir -p /usr/local/docker/mysql/logs
mkdir -p /usr/local/docker/mysql/data

三、定义配置文件
在conf文件夹里创建my.cnf文件,并添加如下配置;

# Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.

#

# This program is free software; you can redistribute it and/or modify

# it under the terms of the GNU General Public License as published by

# the Free Software Foundation; version 2 of the License.

#

# This program is distributed in the hope that it will be useful,

# but WITHOUT ANY WARRANTY; without even the implied warranty of

# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the

# GNU General Public License for more details.

#

# You should have received a copy of the GNU General Public License

# along with this program; if not, write to the Free Software

# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA

#

# The MySQL Server configuration file.

#

# For explanations see

# http://dev.mysql.com/doc/mysql/en/server-system-variables.html

[mysqld]

pid-file = /var/run/mysqld/mysqld.pid

socket = /var/run/mysqld/mysqld.sock

datadir = /var/lib/mysql

secure-file-priv= NULL

# Disabling symbolic-links is recommended to prevent assorted security risks

symbolic-links=0

lower_case_table_names=1

# Custom config should go here

!includedir /etc/mysql/conf.d/

四、启动容器实例

docker run -p 3306:3306 --name mysql8  --restart=always -v /usr/local/docker/mysql/conf/my.cnf:/etc/mysql/my.cnf:rw  -v /usr/local/docker/mysql/logs:/var/log/mysql -v/usr/local/docker/mysql/data:/var/lib/mysql -e MYSQL_ROOT_PASSWORD=root -e  TZ=Asia/Shanghai  -d mysql:8.0

五、其他指令

1、启动docker
systemctl start docker
2、关闭docker
systemctl stop docker
3、重启docker
systemctl restart docker
4、查看docker运行状态
systemctl status docker
5、设置开机自启动
systemctl enable docker
6、删除镜像

删除单个镜像
docker rmi 镜像名/ID

强制删除
docker rmi -f 镜像名/ID

删除多个镜像 空格分割
docker rmi 镜像名/ID 镜像名/ID 镜像名/ID

全部删除
docker rmi -f $(docker images -qa)

相关文章

  • 九、docker安装mysql8.0

    docker安装mysql8.0

  • docker安装mysql8.0

    docker安装mysql8.0 1、查看可用的 MySQL 版本 访问 MySQL 镜像库地址:https://...

  • Docker 安装 MySQL8.0

    环境: centos 7.5 docker 19.03.12 MySQL8.0 docker仓库搜索MySQL...

  • docker安装mysql8.0

    养成良好的记录习惯 时间:2019年10月12日作者:黄黄邮箱:15797683468@163.com(可指出问题...

  • docker安装mysql8.0

    mysql5.7 安装在最后 指定mysql密码 自动生成密码.也可以手动指定 安装 mysql8.0 ​查看My...

  • docker安装mysql8.0

    指定mysql密码 自动生成密码.也可以手动指定 安装 mysql 安装8.0 安装5.7(没测试,应该问题不大)...

  • docker 安装mysql8.0

    拉取镜像 https://hub.docker.com/_/mysql?tab=tags&page=1&order...

  • docker 安装mysql8.0

    参考docker目录下的文章

  • 使用Docker安装MySQL8.0

    1、安装docker 2、拉取MySQL的镜像 运行完以上命令之后,镜像就已经下载下来了 3、查看镜像情况 可以看...

  • 使用Docker安装MySQL8.0

    在阿里云弄了台优惠版的服务器,打算用docker安装MySQL8.0机器是Ubuntu16.04的操作系统 1、安...

网友评论

    本文标题:Docker安装MySql8.0

    本文链接:https://www.haomeiwen.com/subject/drujsdtx.html