The following scripts assist in purging and stopping the build up of binary logs by MySQL see http://technology.blue-bag.com/binary-logs-are-filling-my-mac-help
-
-
Save cdracars/3d8668fac64ae9e892c9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
rem Windows batch file for WAMP | |
@ECHO OFF | |
For /f "tokens=1-3 delims=/ " %%a in ('date /t') do (Set Datestr=%%c-%%b-%%a) | |
FOR /F "TOKENS=*" %%A IN ('TIME/T') DO SET TIME=%%A | |
echo Purging Logs on %Datestr% >> d:/wamp/logs/mysql-log-purge.log | |
@echo off | |
echo. | time /t | |
echo Purge Binary Logs . | |
D:\wamp\bin\mysql\mysql5.1.36\bin\mysql.exe -u root -p -e "PURGE BINARY LOGS BEFORE '%Datestr% 00:00:01';" | |
echo D:\wamp\bin\mysql\mysql5.1.36\bin\mysql.exe -u root -p -e "PURGE BINARY LOGS BEFORE '%Datestr% 00:00:01';" | |
echo Completed, Purged Binary Logs | |
echo. | time /t | |
pause | |
cls | |
if %errorlevel% == 0 goto okay | |
:error | |
echo Error Purging Binary Logs %Datestr% at %Time% >> d:/wamp/logs/mysql-log-purge.log | |
eventcreate /t error /id 100 /so MYSQLPurge /l application /d "MYSqlPurge - Error" | |
goto end | |
:okay | |
rem eventcreate /t information /id 101 /so MYSQLPurge /l application /d "MYSQLPurge - Success" | |
:end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Bash script to run every now and then | |
# source:http://knowledge-republic.com/CRM/2011/05/removing-of-binary-log-bash-script/ | |
user=root | |
password=password | |
mysql -u$user -p$password -bse “show binary logs;” > binary.log | |
LastLine=`tail -n1 binary.log|awk ‘{print $1}’` | |
mysql -u$user -p$password -bse “purge binary logs to ‘”$LastLine”‘;” | |
rm binary.log |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# At the command line | |
# You can clear them up to a date or up to a specific log file: | |
# | |
$ mysql -u root -p 'rootpassword' -e "PURGE BINARY LOGS TO 'mysql-bin.00054';" | |
- or - | |
$ mysql -u root -p 'rootpassword' -e "PURGE BINARY LOGS BEFORE '2013-01-01 10:00:00';" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment