Documentation Home
MySQL Utilities 1.5 Manual
Related Documentation Download this Manual
PDF (US Ltr) - 1.2Mb
PDF (A4) - 1.2Mb
EPUB - 365.4Kb
HTML Download (TGZ) - 287.5Kb
HTML Download (Zip) - 298.6Kb

MySQL Utilities 1.5 Manual  /  ...  /  How Do I Copy/Move The Audit Log?

3.6.2 How Do I Copy/Move The Audit Log?

The audit log information can grow quickly and considerably depending on the type of information written to the audit log files and the activity of the MySQL server. Therefore, it might be a good idea to copy the audit log files to a different location and free some storage on the server.

The mysqlauditadmin utility also provides this useful functionality.


The goal of this task is to copy an existing audit log file to a different location using the mysqlauditadmin utility.

It is assumed that the utility is executed on the destination host which must be a non-Windows system with the scp (Secure CoPy) command line program, and that must have access to the MySQL remote server and its data directory with the provided credentials (user and password). It is also assumed that the specified audit log file exists and user has write privileges on the target directory.

Example Execution

shell> mysqlauditadmin --audit-log-name=/MySQL/SERVER/data/audit.log.13753706179878237 \
          copy --copy-to=/ARCHIVE/Audit_Logs --remote-login=user1:server1 
# Copying file from server1:/MySQL/SERVER/data/audit.log.13753706179878237 to /ARCHIVE/Audit_Logs:
user1@server1's password: 
audit.log.13753706179878237                   100% 4716     4.6KB/s   00:01        


The copy operation can be performed with the mysqlauditadmin utility using the 'copy' command and requiring the following options: the --audit-log-name option to specify the path and filename of the audit log file to copy, the --copy-to option to indicate the destination folder, and in this example the --remote-login option to specify the user and remote host where the file is located (the user password will be prompted).

The --remote-login option is not required if the source and destination location are on the same server where the utility is executed. Moreover, this option is not supported in Windows system where UNC paths should be used instead.

Permissions Required

The user must have permissions to read the audit log on disk and write the file to the remove location.

Tips and Tricks

The name of the audit log file (audit.log, by default) is defined by the audit_log_file variable displayed by mysqlauditadmin when using the --show-options option. Existing audit log files have a timestamp extension except the one that is currently in use. That being said, it might be useful to know that it is possible to get information about the existing audit log files using mysqlrpladmin, for instance to determine which files need to be copied. To get this information use the --file-stats option and the --audit-log-name option specifying the full path of the current audit log file (i.e., without the timestamp extension). For example:

shell> mysqlauditadmin --file-stats --audit-log-name=/MySQL/SERVER/data/audit.log
| File                         | Size       | Created                   | Last Modified             |
| audit.log.13753706179878237  | 4716       | Thu Aug  1 16:23:37 2013  | Thu Aug  1 16:23:37 2013  |
| audit.log                    | 6062       | Thu Aug  1 16:24:26 2013  | Thu Aug  1 16:24:26 2013  |
| audit.log.13753705495049727  | 335142503  | Thu Aug  1 16:22:29 2013  | Thu Aug  1 16:22:29 2013  |


If an audit log file with the timestamp extension is specified in this example for the --audit-log-name option, only the information of the specified file will be displayed, as opposed to the file statistics of all existing files.

Download this Manual
PDF (US Ltr) - 1.2Mb
PDF (A4) - 1.2Mb
EPUB - 365.4Kb
HTML Download (TGZ) - 287.5Kb
HTML Download (Zip) - 298.6Kb
User Comments
Sign Up Login You must be logged in to post a comment.