MariaDB / mariadb-docker

Docker Official Image packaging for MariaDB
https://mariadb.org
GNU General Public License v2.0
755 stars 436 forks source link

how to map the error log file to host machine? #542

Closed ihola777 closed 8 months ago

ihola777 commented 8 months ago

seems like mariadb doesn't create error log file in container and nothing in /var/log/mysql. how can i change the configuration to make this happen ? thx

my.cnf

[client-server]
# Port or socket location where to connect
bind-address = 127.0.0.1
port = 3306
socket = /run/mysqld/mysqld.sock

# Import all .cnf files from configuration directory
[mariadbd]

# Custom Encoding And Collation
collation-server = utf8mb4_unicode_ci
character-set-server = utf8mb4

# log
log_error = /var/log/mysql/error.log

docker-compose.yml

version: '3.7'
services:
    db:
        image: mariadb:latest
        restart: unless-stopped
        ports:
            - 3306:3306
        volumes:
            - $PWD/data:/var/lib/mysql
            - /var/log/mysql:/var/log/mysql
            - $PWD/conf:/etc/mysql/conf.d
            - $PWD/initdb.d:/docker-entrypoint-initdb.d
        environment:
            MYSQL_DATABASE: xxxxx
            MYSQL_USER: xxxxx
            MYSQL_PASSWORD: xxxxx
            MYSQL_RANDOM_ROOT_PASSWORD: '1'
        ulimits:
            memlock: 262144
        container_name: db
        networks:
            - db

os: Linux tuna 5.10.0-0.deb10.16-amd64 #1 SMP Debian 5.10.127-2~bpo10+1 (2022-07-28) x86_64 GNU/Linux

grooverdan commented 8 months ago

your configuration is right, its most likely that /var/log/mysql isn't owned by the mysql user within the container, so execute the following and try again:

docker run -v /var/log/mysql:/var/log/mysql --rm  mariadb:latest chown mysql: /var/log/mysql 
grooverdan commented 8 months ago

working as expected?

ihola777 commented 8 months ago

working as expected?

thanks for your kindly help. i found it's acutally a typo issue.