• Categories
    Category
  • Categories
    Category
  • News
  • Tutorials
  • Forums
  • Tags
  • Users
Tutorial Comments FAQ Related Articles

How to create MySQL logrotate on centos 7.6

  • 00:35 rpm -q centos-release
  • 00:49 cd /etc/logrotate.d/
  • 01:04 vim mysql_new
  • 03:07 vim /var/log/mysqld.log
  • 03:24 cd /mnt
  • 03:28 mkdir test
  • 03:40 logrotate -f /etc/logrotate.d/mysql_new
  • 03:57 cd test
  • 04:10 gunzip mysqld.log.1.gz
  • 04:19 vim mysqld.log.1
  • 04:28 vim /var/log/mysqld.log
6274

Method to create MySQL logrotate on Centos 7.6

Installation process

Check the centos version by using the following command

[root@linuxhelp ~]# rpm -q centos-release
centos-release-7-6.1810.2.el7.centos.x86_64

Enter into the logrotate directory

[root@linuxhelp ~]# cd /etc/logrotate.d/

List out the file

[root@linuxhelp logrotate.d]# ls -la
total 68
drwxr-xr-x.   2 root root  214 Jan 12 01:13 .
drwxr-xr-x. 138 root root 8192 Jan 12 05:17 ..
-rw-r--r--.   1 root root   91 Apr 11  2018 bootlog
-rw-r--r--.   1 root root  160 Sep 15  2017 chrony
-rw-r--r--.   1 root root   71 Apr 11  2018 cups
-rw-r--r--.   1 root root  172 Sep 30  2016 iscsiuiolog
-rw-r--r--.   1 root root  165 Oct 31  2018 libvirtd
-rw-r--r--.   1 root root  142 Oct 31  2018 libvirtd.qemu
-rw-r--r--    1 root root  972 Sep 20 15:03 mysql
-rw-r--r--.   1 root root  106 Apr 11  2018 numad
-rw-r--r--.   1 root root  136 Jun 10  2014 ppp
-rw-r--r--.   1 root root  408 Aug  3  2017 psacct
-rw-r--r--.   1 root root  115 Oct 31  2018 samba
-rw-r--r--.   1 root root  224 Oct 30  2018 syslog
-rw-r--r--.   1 root root  100 Oct 31  2018 wpa_supplicant
-rw-r--r--.   1 root root  103 Nov  5  2018 yum

Create new file for mysql logrotate in the directory

[root@linuxhelp logrotate.d]# vim mysql_new
/var/log/mysqld.log {
create 600 mysql mysql
notifempty
daily
rotate 5
missingok
compress
size 100M
olddir /mnt/test/
}

Check the mysql log by using the following command

[root@linuxhelp logrotate.d]# vim /var/log/mysqld.log
020-01-11T23:47:30.922794Z 0 [System] [MY-013169] [Server] /usr/sbin/mysqld (mysqld 8.0.18) initializing of server in progress as process 9411
2020-01-11T23:47:40.990156Z 5 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: +wMsqW%AE3hk
2020-01-11T23:47:45.486431Z 0 [System] [MY-010116] [Server] /usr/sbin/mysqld (mysqld 8.0.18) starting as process 10197
2020-01-11T23:47:49.068967Z 0 [Warning] [MY-010068] [Server] CA certificate ca.pem is self signed.
2020-01-11T23:47:49.206560Z 0 [System] [MY-010931] [Server] /usr/sbin/mysqld: ready for connections. Version: '8.0.18'  socket: '/var/lib/mysql/mysql.sock'  port: 3306  MySQL Community Server - GPL.
2020-01-11T23:47:49.428623Z 0 [System] [MY-011323] [Server] X Plugin ready for connections. Socket: '/var/run/mysqld/mysqlx.sock' bind-address: '::' port: 33060

Enter into the following directory

[root@linuxhelp logrotate.d]# cd /mnt

Create the test directory

[root@linuxhelp mnt]# mkdir test

Run the following command to execute the logrotate for MySQL by force

[root@linuxhelp mnt]# logrotate -f /etc/logrotate.d/mysql_new

Enter into test directory

[root@linuxhelp mnt]# cd test

List out the file

[root@linuxhelp test]# ls -la
total 4
drwxr-xr-x  2 root  root   29 Jan 12 05:32 .
drwxr-xr-x. 4 root  root   30 Jan 12 05:32 ..
-rw-r-----  1 mysql mysql 441 Jan 12 05:31 mysqld.log.1.gz

Extract the file using gunzip command

[root@linuxhelp test]# gunzip mysqld.log.1.gz

List out the file

[root@linuxhelp test]# ls -la
total 4
drwxr-xr-x  2 root  root   26 Jan 12 05:32 .
drwxr-xr-x. 4 root  root   30 Jan 12 05:32 ..
-rw-r-----  1 mysql mysql 847 Jan 12 05:31 mysqld.log.1

Now you can see the mysql log in the following directory

[root@linuxhelp test]# vim mysqld.log.1
020-01-11T23:47:30.922794Z 0 [System] [MY-013169] [Server] /usr/sbin/mysqld (mysqld 8.0.18) initializing of server in progress as process 9411
2020-01-11T23:47:40.990156Z 5 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: +wMsqW%AE3hk
2020-01-11T23:47:45.486431Z 0 [System] [MY-010116] [Server] /usr/sbin/mysqld (mysqld 8.0.18) starting as process 10197
2020-01-11T23:47:49.068967Z 0 [Warning] [MY-010068] [Server] CA certificate ca.pem is self signed.
2020-01-11T23:47:49.206560Z 0 [System] [MY-010931] [Server] /usr/sbin/mysqld: ready for connections. Version: '8.0.18'  socket: '/var/lib/mysql/mysql.sock'  port: 3306  MySQL Community Server - GPL.
2020-01-11T23:47:49.428623Z 0 [System] [MY-011323] [Server] X Plugin ready for connections. Socket: '/var/run/mysqld/mysqlx.sock' bind-address: '::' port: 33060

The previous log has been removed

[root@linuxhelp test]# vim /var/log/mysqld.log

This is the method to create MySQL logrotate on centos 7.6 comes to end

Tags:
connor
Author: 

Comments ( 0 )

No comments available

Add a comment

Frequently asked questions ( 5 )

Q

What is logrotate?

A

logrotate is designed to ease administration of systems. It allows automatic rotation, compression, removal, and mailing of log files.
Log Rotation depends on weekly, monthly and yearly, or size

Q

How to specify a date in the rotated log file?

A

To specify a date in rotated log file use the below option in the configuration file
date text

Q

How to mail the rotated log to the Administrator?

A

To mail the rotated log to the Administrator use the below option in the configuration
mail abc@gmail.com

Q

How to store the rotated log in a specific location?

A

To store the rotated log in specific location use the below option in the configuration
olddir

Q

What is the use of notifoption in configuration?

A

The use of notifempty option in the configuration is skipped logrotate if the file is empty

Related Tutorials in How to create MySQL logrotate on centos 7.6

Related Tutorials in How to create MySQL logrotate on centos 7.6

How To Install AnyDesk on Centos 7
How To Install AnyDesk on Centos 7
Apr 2, 2018
How to install Tiki Wiki CMS Groupware on CentOS 7
How to install Tiki Wiki CMS Groupware on CentOS 7
May 31, 2018
How to install PHP ImageMagick on CentOS 7
How to install PHP ImageMagick on CentOS 7
Nov 4, 2017
How to Upgrade and Downgrade the PHP Versions on CentOS 7.6
How to Upgrade and Downgrade the PHP Versions on CentOS 7.6
Jun 4, 2019
How to install Apache from Source Code on CentOS 7
How to install Apache from Source Code on CentOS 7
Oct 21, 2017
How to enable or disable repositories in CentOS
How to enable or disable repositories in CentOS
Mar 28, 2018
How to install AWStats on CentOS 7
How to install AWStats on CentOS 7
Dec 8, 2017
How to install Apache JMeter in CentOS 7
How to install Apache JMeter in CentOS 7
Mar 24, 2017

Related Forums in How to create MySQL logrotate on centos 7.6

Related Forums in How to create MySQL logrotate on centos 7.6

CentOS
connor class=
How To Completely Remove Apache package On CentOS 7.6
May 14, 2019
CentOS
ceriaimmaculate class=
setfacl : command not found
Jan 3, 2018
CentOS
mason class=
Error getting authority: Error initializing authority: Could not connect: No such file or directory (g-io-error-quark, 1)
Nov 20, 2018
CentOS
landon class=
Command to find SNMP Version
May 28, 2018
CentOS
arjitharon class=
cannot start minio service help
Mar 10, 2018
Apache tomcat
AadrikaAnshu class=
Cannot find ./catalina.sh The file is absent or does not have execute permission This file is needed to run this program
Jun 17, 2019
gitlab
caden class=
Insufficient space in download directory /var/cache/yum/x86_64/6/base/packages
Jul 22, 2019
OpenVAS
frank class=
Could not retrieve mirrorlist http://mirrorlist.centos.org/?release=7&arch=x86_64&repo=os&infra=stock error was 14: curl#6 - "Could not resolve host: mirrorlist.centos.org; Unknown error"
Dec 20, 2018
Back To Top!
Rank
User
Points

Top Contributers

userNamenaveelansari
135850

Top Contributers

userNameayanbhatti
92510

Top Contributers

userNamehamzaahmed
32150

Top Contributers

1
userNamelinuxhelp
31040

Top Contributers

userNamemuhammadali
24500
Can you help Sebastian ?
How to change non required to required field in SuiteCRM Custom/Default Modules

How to change not required to the required field in SuiteCRM Custom/Default Modules?

Networking
  • Routing
  • trunk
  • Netmask
  • Packet Capture
  • domain
  • HTTP Proxy
Server Setup
  • NFS
  • KVM
  • Memory
  • Sendmail
  • WebDAV
  • LXC
Shell Commands
  • Cloud commander
  • Command line archive tools
  • last command
  • Shell
  • terminal
  • Throttle
Desktop Application
  • Linux app
  • Pithos
  • Retrospect
  • Scribe
  • TortoiseHg
  • 4Images
Monitoring Tool
  • Monit
  • Apache Server Monitoring
  • EtherApe 
  • Arpwatch Tool
  • Auditd
  • Barman
Web Application
  • Nutch
  • Amazon VPC
  • FarmWarDeployer
  • Rukovoditel
  • Mirror site
  • Chef
Contact Us | Terms of Use| Privacy Policy| Disclaimer
© 2025 LinuxHelp.com All rights reserved. Linux™ is the registered trademark of Linus Torvalds. This site is not affiliated with linus torvalds in any way.