docker安装mariadb,并开启binlog

拉取mariadb镜像

docker pull mariadb

配置文件名称叫 mariadb.cnf

# 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
[mariadbd]
skip-host-cache
skip-name-resolve

[mysqld]
datadir=/var/lib/mysql
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid
log_bin=/var/lib/mysql/mysql-bin
log_bin_index=/var/lib/mysql/mysql-bin.index
server-id=1
binlog_format=row

!includedir /etc/mysql/mariadb.conf.d/
!includedir /etc/mysql/conf.d/

启动镜像,这里的 /root/mysql/mariadb.cnf:/etc/mysql/mariadb.cnf
前面 /root/mysql/mariadb.cnf 是你的本地路径,后面 /etc/mysql/mariadb.cnf 是固定的,不要修改

docker run -itd --name mariadb-test -v /root/mysql/mariadb.cnf:/etc/mysql/mariadb.cnf  -p 3306:3306 -e MYSQL_ROOT_PASSWORD=123456 mariadb

猜你喜欢

转载自blog.csdn.net/weixin_44388689/article/details/121096229