Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a MySQL 5.5 service (RHEL 5.x) with a ~350Gb access log file. I'd like to zero this file out. Do I need to do anything special before-hand? Stop the server?

share|improve this question

closed as off-topic by mdpc, Katherine Villyard, Ward, Jenny D, Tim Brigham Mar 12 '14 at 18:16

This question appears to be off-topic. The users who voted to close gave these specific reasons:

  • "Questions must demonstrate a minimal understanding of the problem being solved. Try including attempted solutions, why they didn't work, and the expected results. See How can I ask better questions on Server Fault? for further guidance." – Ward, Tim Brigham
  • "Questions must be relevant to professional system administration. Server Fault is dedicated to professional system and network administrators. End user and enthusiast questions are off-topic (contact your system administrator or hire a professional to help you out). Please see the Help Center for more information." – mdpc, Katherine Villyard, Jenny D
If this question can be reworded to fit the rules in the help center, please edit the question.

rename the file, use touch to create an empty file with the same name, permissions. Restart the server. – Zoredache Mar 5 '14 at 22:11
up vote 3 down vote accepted

First you rename the log file, then you issue the command FLUSH LOGS which causes MySQL to close and reopen the file. Since that file doesn't exist, it'll create a new one.

Then do whatever you want with the original file.

No restart necessary.

share|improve this answer
shell> cd mysql-data-directory
shell> mv mysql.log mysql.old
shell> mv mysql-slow.log mysql-slow.old
shell> mysqladmin flush-logs

refer to : MySQL :: MySQL 5.0 Reference Manual :: 5.2.5 Server Log Maintenance

share|improve this answer

What is access log in MySQL? You mean general_log? Anyway, rotate any MySQL log with logrotate. Here's sample config. Change log file names.

/root/.my.cnf must store user and password to connect to MySQL

# cat /etc/logrotate.d/mysql
/var/lib/mysql/mysql-error.log /var/lib/mysql/general.log {
    rotate 7
    size 1G
    create 640 mysql mysql
            test -x /usr/bin/mysqladmin || exit 0
            MYADMIN="/usr/bin/mysqladmin --defaults-file=/root/.my.cnf"
            if [ -z "`$MYADMIN ping 2>/dev/null`" ]; then
              if ps cax | grep -q mysqld; then
                exit 1
              $MYADMIN flush-logs


share|improve this answer

cat /dev/null > your_access_log_file - No service restart required, but it will take a while to zero out 350GB

share|improve this answer

Not the answer you're looking for? Browse other questions tagged or ask your own question.