Database

How To Change MySQL Binary Log File Location To Another Directory

By default, in most installation binary log files are located in MySQL default director “/var/lib/mysql/“.

Each data modification such as INSERT, UPDATE, DELETE and data definition such as ALTER, ADD, DROP statement that you perform in your server are record in log files. So each time when you make any these statements, you actually update both your data files and your log file. So there is high IO utilization that focused on a specific disk area. For better performance a common way is separate these files to two different disks.

Change MySQL Binary Log File Location To Another Directory

Follow the below steps to change MySQL binary log file location to another directory.

1. Edit the log-bin variable in my.cnf file located in /etc/my.cnf to log-bin=/new/directory/path/mysql-bin .

# vim /etc/my.cnf
......
.........
log-bin=/new/directory/path/mysql-bin
.....
.......

Save and close the file.

2. To minimize the number of moved files, purge as many files as you can ( PURGE BINLOG…).

3. Stop MySQL server.

# service mysqld stop

4. Now move the all mysql-bin file to new directory.

# mv /var/lib/mysql/mysql-bin.* /new/directory/path

5. Start MySQL server again.

# service mysqld start

That’s it.

Thanks:)

Thank you! for visiting LookLinux.

If you find this tutorial helpful please share with your friends to keep it alive. For more helpful topic browse my website www.looklinux.com. To become an author at LookLinux Submit Article. Stay connected to Facebook.

About the author

mm

Santosh Prasad

Hi! I'm Santosh and I'm here to post some cool article for you. If you have any query and suggestion please comment in comment section.

Leave a Comment