在centos中为mysql设置bin log很简单,只需要取消注释/etc/my.cnf
my.cnf中 . 之前的行即可。
#log_bin = /var/log/mysql/mysql-bin.log
在 my.cnf 中取消其注释。
log_bin = /var/log/mysql/mysql-bin.log
/etc/my.cnf
在debian9的mariadb中没有。1
.在debian9中添加log_bin目录mysql.cnf
。
sudo vim /etc/mysql/conf.d/mysql.cnf
log_bin = /var/log/mysql/mysql-bin.log
sudo touch /var/log/mysql/mysql-bin.log
sudo chown mysql.mysql /var/log/mysql/mysql-bin.log
sudo systemctl restart mysql
sudo systemctl status mysql
● mariadb.service - MariaDB database server
Loaded: loaded (/lib/systemd/system/mariadb.service; enabled; vendor preset:
Active: active (running) since Thu 2019-05-02 08:16:54 CST; 24s ago
设置似乎没有问题。
mysql -u root -p
mysql: unknown variable 'log_bin=/var/log/mysql/mysql-bin.log'
2.在debian9的中添加log_bin目录50-server.cnf
。
sudo vim /etc/mysql/mariadb.conf.d/50-server.cnf
log_bin = /var/log/mysql/mysql-bin.log
现在重新启动mysql。
sudo systemctl restart mysql
Job for mariadb.service failed because the control process exited with error code.
See "systemctl status mariadb.service" and "journalctl -xe" for details.
发生了什么?
sudo journalctl -xe
--
-- Unit mariadb.service has finished shutting down.
May 02 08:32:26 debian systemd[1]: Starting MariaDB database server...
-- Subject: Unit mariadb.service has begun start-up
-- Defined-By: systemd
-- Support: https://www.debian.org/support
--
-- Unit mariadb.service has begun starting up.
May 02 08:32:27 debian mysqld[3640]: 2019-05-02 8:32:27 140494098832768 [Note]
May 02 08:32:30 debian systemd[1]: mariadb.service: Main process exited, code=ex
May 02 08:32:30 debian systemd[1]: Failed to start MariaDB database server.
如何在 debian9 中为 Maradb 设置 bin log?
答案1
在我的电脑上测试多次。
sudo apt install mariadb-client mariadb-server
可以启用 bin log,同样的流程,sudo apt install mariadb-server
无法启用 bin log,虽然sudo apt install mariadb-server
会触发操作系统安装mariadb-client
,但不知道为什么。