By default, mariaDB never write logs hers for you. Sure, it’s her privacy that she doesn’t want others to know. However, you can enable her logging like this:

Make your logs folder and change permission:

mkdir /var/log/mariadb/
chown -R mysql. /var/log/mariadb/

Edit this file /etc/my.cnf.d/server.conf or /etc/my.cnf.d like as below:

[mariadb]
slow_query_log                  = 1
slow_query_log_file             = /var/log/mariadb/slow.log
long_query_time                 = 1
log_error                       = /var/log/mariadb/error.log
general_log_file                = /var/log/mariadb/mysql.log
general_log                     = 1

[client-server]
!includedir /etc/my.cnf.d' > /etc/my.cnf

Restart your mariadb:

systemctl restart mariadb

Now, you have three file:

/var/log/mariadb/error.log

  • This logs records mariadb service error

/var/log/mariadb/mysql.log

  • This logs records all Query logs

/var/log/mariadb/slow.log

  • This log records all “Slow queries”. This helps you find where server performance is affected.

Change rotate config at /etc/logrotate.d/mariadb. Test rotate: sudo logrotate –force /etc/logrotate.d/mariadb


Leave a Reply

Your email address will not be published. Required fields are marked *