docker 安裝 mysql 並且外掛文件目錄


1. 拉取docker 鏡像

docker  pull mysql

2. 創建掛載目錄

mkdir /docker/mysql/conf
mkdir /docker/mysql/data
mkdir /docker/mysql/log

3. 創建my.cnf文件

cd /docker/mysql/conf
vi my.cnf

4. 插入以下內容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/

5. 創建並且啟動docker

docker run \
    -p 3306:3306 \
    -e MYSQL_ROOT_PASSWORD=test@123 \
    -v /docker/mysql/data:/var/lib/mysql \
    -v /docker/mysql/log:/logs \
    -v /docker/mysql/conf/my.cnf:/etc/mysql/my.cnf \
    --name mysql_1 \
    --restart=always \
    -d mysql:latest

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM