使用docker-compose安装mariadb

4 篇文章 0 订阅
  • step1: 创建目录

    mkdir -p /server/mariadb/{config,data,log}
    chmod -R 777 /server/mariadb
    
  • step2: 编写docker-compose.yml

    version: '3.1'
    services:
      mariadb:
        image: mariadb:10.5.5
        container_name: "mariadb1"
        restart: always
        environment:
          MYSQL_USER: "root"
          MYSQL_PASSWORD: "123456"
          MYSQL_ROOT_PASSWORD: "123456"
          TZ: "Asia/Shanghai"
        ports:
          - "3306:3306"
        volumes:
          - ./data:/var/lib/mysql
          - ./log:/var/log/mysql
          - ./conf/my.cnf:/etc/mysql/my.cnf
    
  • step3: 拷贝/etc/mysql/my.cnf 到 /server/mariadb/conf/my.cnf

    docker exec -it mariadb1 bash
    

    此时目录树:

    - server/
    - mariadb/
        - data/
        - log/
        - config/
            - my.cnf
        - docker-compose.yml
    
    # The MariaDB configuration file
    #
    # The MariaDB/MySQL tools read configuration files in the following order:
    # 0. "/etc/mysql/my.cnf" symlinks to this file, reason why all the rest is read.
    # 1. "/etc/mysql/mariadb.cnf" (this file) to set global defaults,
    # 2. "/etc/mysql/conf.d/*.cnf" to set global options.
    # 3. "/etc/mysql/mariadb.conf.d/*.cnf" to set MariaDB-only options.
    # 4. "~/.my.cnf" to set user-specific options.
    #
    # If the same option is defined multiple times, the last one will apply.
    #
    # One can use all long options that the program supports.
    # Run program with --help to get a list of available options and with
    # --print-defaults to see which it would actually understand and use.
    #
    # If you are new to MariaDB, check out https://mariadb.com/kb/en/basic-mariadb-articles/
    
    #
    # This group is read both by the client and the server
    # use it for options that affect everything
    #
    [client-server]
    # Port or socket location where to connect
    # port = 3306
    socket = /run/mysqld/mysqld.sock
    
    # Import all .cnf files from configuration directory
    !includedir /etc/mysql/conf.d/
    !includedir /etc/mysql/mariadb.conf.d/
    
    
  • step4: 运行启动

    docker-compose up -d
    
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Spaceack

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值