Docker安装mysql8
一、下载mysql8镜像
docker pull mysql
二、创建mysql8配置文件
vi /etc/my.cnf #编辑MySQL配置文件
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
# Custom config should go here
!includedir /etc/mysql/conf.d/
三、创建mysql容器
docker run -p 60306:3306 -e MYSQL_ROOT_PASSWORD=123 -v /etc/my.cnf:/etc/mysql/my.cnf:rw -v /etc/localtime:/etc/localtime:ro --name mysql8 --restart=always -dit mysql
-p 60306:3306 #本机60306端口映射到容器3306端口
-e MYSQL_ROOT_PASSWORD=123 #设置MySQL的root用户密码
-v /etc/my.cnf:/etc/mysql/my.cnf:rw #本机的MySQL配置文件映射到容器的MySQL配置文件
-v /etc/localtime:/etc/localtime:ro #本机时间与数据库时间同步
--name mysql8 #设置容器别名
--restart=always #当重启Docker时会自动启动该容器
-dit mysql #后台运行并可控制台接入
四、进入mysql控制台
docker exec -it b6cfb244d0c0 bash #进入MySQL容器
mysql -uroot -p123 #进入MySQL控制台
ALTER USER 'root'@'%' IDENTIFIED WITH mysql_native_password BY '123456'; #修改root用户密码

低调大师中文资讯倾力打造互联网数据资讯、行业资源、电子商务、移动互联网、网络营销平台。
持续更新报道IT业界、互联网、市场资讯、驱动更新,是最及时权威的产业资讯及硬件资讯报道平台。
转载内容版权归作者及来源网站所有,本站原创内容转载请注明来源。
-
上一篇
kubernetes的存储ConfigMap
kubernetes的存储ConfigMap 标签(空格分隔): kubernetes系列 一: kubernetes的存储ConfigMap 一:kubernetes的存储 1.1 configMap 描述信息 ConfigMap 功能在 Kubernetes1.2 版本中引入,许多应用程序会从配置文件、命令行参数或环境变量中读取配 置信息。ConfigMap API 给我们提供了向容器中注入配置信息的机制,ConfigMap 可以被用来保存单个属性,也 可以用来保存整个配置文件或者 JSON 二进制大对象 配置中心: 1.1.1 configmap 的创建 1. 使用目录创建 $ ls docs/user-guide/configmap/kubectl/ game.properties ui.properties $ cat docs/user-guide/configmap/kubectl/game.properties enemies=aliens lives=3 enemies.cheat=true enemies.cheat.level=noGoodRotten secre...
-
下一篇
心选建站云解析
云栖号在线课堂,及时了解行业动态!阿里云推出疫情专题方案,为企业业务护航,让你足不出户了解行业动态。 在这里可以走近阿里云基础产品,了解更多应用方案,还能遇见大咖分享洞见及故事!也可以通过视频的形式让你高效、生动的了解场景化的上云最佳实践。 本周重磅直播 采购季直播间 - 7大会场攻略 -> 心选建站云解析 日期 直播主题 直播间link 3月16日 从传统应用到云原生,云时代的开发运维演变 https://yq.aliyun.com/live/2198 3月16日 创业不易,阿里云助力中小企业在线复工! https://yq.aliyun.com/live/2314 3月18日 云上CI/CD最佳实践 https://yq.aliyun.com/live/2200 3月19日 在线业务弹性扩缩容最佳实践 https://yq.aliyun.com/live/2201 3月19日 低成本高性价比的建站秘籍 https://yq.aliyun.com/live/2308 3月20日 教你打造企业品牌门户 https://yq.aliyun.com/live/2309 架构师成长系列...
相关文章
文章评论
共有0条评论来说两句吧...
文章二维码
点击排行
推荐阅读
最新文章
- SpringBoot2整合MyBatis,连接MySql数据库做增删改查操作
- Docker使用Oracle官方镜像安装(12C,18C,19C)
- Springboot2将连接池hikari替换为druid,体验最强大的数据库连接池
- MySQL数据库在高并发下的优化方案
- Docker快速安装Oracle11G,搭建oracle11g学习环境
- SpringBoot2编写第一个Controller,响应你的http请求并返回结果
- CentOS7,8上快速安装Gitea,搭建Git服务器
- CentOS6,7,8上安装Nginx,支持https2.0的开启
- CentOS8编译安装MySQL8.0.19
- Dcoker安装(在线仓库),最新的服务器搭配容器使用