I have a MySQL database running with binary logging turned on. Each time the database is restarted a new binary log file is created in the format :
mysql-bin.00001
mysql-bin.00002
...
mysql-bin.0000n
My question is, is there a way to have the binary log file stay the same after each database restart.
So for example it's always mysql-bin.00001
Any help would be greatly appreciated.
Best Answer
There are five(5) methods you can do
METHOD #1
Don't run restart. Delete the binlogs between shutdown and startup.
Let's say
mysql-bin.*
is in/var/lib/mysql
. Run the following:After startup, login to mysql and run
an you should see
mysql-bin.000001
METHOD #2
Create a script to execute
RESET MASTER;
and have it executedStep 01 : Add this line to
my.cnf
under the[mysqld]
group headerStep 02 : Run the following
Step 03 :
service mysql restart
METHOD #3
Do it by hand. Login to mysql and run
METHOD #4
Erase binary logs immediately after restart
METHOD #5 (Permanent)
Step 01 : Go to
my.cnf
and comment out thelog-bin
optionor delete the line that says log-bin=mysql-bin
Step 02 : Run the following
Step 03 : Login to mysql and run
The output should be
GIVE IT A TRY !!!