欢迎各位兄弟 发布技术文章

这里的技术是共享的

You are here

修改 mysql-binlog 二进制日志文件至其它目录 MySQL binlog日志存放位置的修改 有大用

修改 mysql-binlog 二进制日志文件至其它目录

myql默认配置情况下,二进制日志文件是保存在默认的数据目录 data 下,如:/usr/local/mysql/data。
有时我们希望把 binlog 修改保存到其他目录下,现记录下操作过程。
假设原目录为: /usr/local/mysql/data,并且已有一些日志文件 mysql-bin.??????
新目录为: /data/mysql/data

mysql.server stop

vi /etc/my.cnf
修改 log-bin=mysql-binlog-bin=/data/mysql/data/mysql-bin

mkdir -p /data/mysql/data
chown -R mysql /data/mysql/data
chgrp -R mysql /data/mysql/data

cp /usr/local/mysql/data/mysql-bin.* /data/mysql/data

vi /data/mysql/data/mysql-bin.index
把每一行的文件路径改为新目录的绝对路径
既 ./mysql-bin.?????? 改为 /data/mysql/data/mysql-bin.??????

mysql.server start

来自  https://blog.csdn.net/jiao_fuyou/article/details/78366621




ysql 数据库日志与数据文件分开

参考:
https://blog.csdn.net/jiao_fuyou/article/details/78366621

myql默认配置情况下,二进制日志文件是保存在默认的数据目录 data 下,如:/usr/local/mysql/data。
有时我们希望把 binlog 修改保存到其他目录下,现记录下操作过程。
假设原目录为: /usr/local/mysql/data,并且已有一些日志文件 mysql-bin.??????
新目录为: /var/log/mysql/

 

1. 停止数据库
systemctl stop mysqld.service

 

2. 修改日志存放路径:

vi /etc/my.cnf
修改 log-bin=mysql-bin 为 log-bin=/var/log/mysql/mysql-bin

mkdir -p /var/log/mysql/
chown -R mysql /var/log/mysql/
chgrp -R mysql /var/log/mysql/

cp /var/lib/mysql/mysql-bin.* /var/log/mysql/

 

3. 修改新路径

vi /var/log/mysql/mysql-bin.index
把每一行的文件路径改为新目录的绝对路径
即 ./mysql-bin.?????? 改为/var/log/mysql/mysql-bin.??????


/var/log/mysql/mysql-bin.000001
/var/log/mysql/mysql-bin.000002
/var/log/mysql/mysql-bin.000003
/var/log/mysql/mysql-bin.000004
/var/log/mysql/mysql-bin.000005
/var/log/mysql/mysql-bin.000006
/var/log/mysql/mysql-bin.000007
/var/log/mysql/mysql-bin.000008
/var/log/mysql/mysql-bin.000009
/var/log/mysql/mysql-bin.000010
/var/log/mysql/mysql-bin.000011
/var/log/mysql/mysql-bin.000012

4.启动数据库
mysql.server start

来自  https://www.cnblogs.com/xiaoer/p/9895063.html

普通分类: