码迷,mamicode.com
首页 > 数据库 > 详细

docker 安装 mysql

时间:2020-03-12 12:52:38      阅读:77      评论:0      收藏:0      [点我收藏+]

标签:docker 安装   意思   redist   def   native   comm   end   mysql   serve   

配置

 

 

# 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/

default_authentication_plugin= mysql_native_password

  

安装

docker pull mysql

docker run     -p 3306:3306     -e MYSQL_ROOT_PASSWORD=123456     -v /home/data/mysql/data:/var/lib/mysql:rw     -v /home/data/mysql/log:/var/log/mysql:rw     -v /home/data/mysql/config/my.cnf:/etc/mysql/my.cnf:rw     -v /etc/localtime:/etc/localtime:ro     --name mysql8     --restart=always     -d mysql

mysql/data 是数据库文件存放的地方。必须要挂载到容器外,否则容器重启一切数据消失。
mysql/log 是数据库主生的log。建议挂载到容器外。
mysql/config/my.cnf 是数据库的配置文件,在下面会放出来。
/etc/localtime:/etc/localtime:ro 是让容器的时钟与宿主机时钟同步,避免时区的问题,ro是read only的意思,就是只读。

  

 

docker 安装 mysql

标签:docker 安装   意思   redist   def   native   comm   end   mysql   serve   

原文地址:https://www.cnblogs.com/fmp/p/12468371.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!