15

I am using new relic to monitor the performance of my server. Recently I noticed a very strange problem where for every 3 hours, the server will be down for 1 minute. And in the new relic report, during the server down time, there were sudden spike on the database.

The problem is I am new in system admin, I don't know how to view the database log. I am using Mariadb on a Ubuntu 14.04 machine. So, where can I find the log? I tried to view in /var/log/mysql.err, /var/log/mysql.log and /var/log/mysql/error.log there are no content inside.

I also tried grep 'mysql' /var/log/syslog, nothing found as well.

Do I need to enable the logging in mariadb config file? If so, how?

dev-jim
  • 283
  • 1
  • 2
  • 8

4 Answers4

15

One of the ways to find out your current log file path is using the following SQL query:

show global variables like 'log_error';

The output should look something like this:

+---------------+---------------------+
| Variable_name | Value               |
+---------------+---------------------+
| log_error     | /var/log/mysqld.log |
+---------------+---------------------+
Tubeless
  • 1,492
  • 13
  • 15
  • it shows /var/log/mysql/error.log, but no content in the log. I also try `show global variables like 'log';` It show log : OFF, seem the loggin is turned off. How do I enable it? – dev-jim Nov 22 '15 at 06:25
  • 1
    No, [log variable](https://dev.mysql.com/doc/refman/5.5/en/server-options.html#option_mysqld_log) is related to general query logging. It could be that MySQL doesn't have privileges to write in `/var/log/mysql/error.log`. Can you check the current permissions and ownership by running `ls -la /var/log/mysql/error.log`? Your MySQL server is most probably running under "mysql" user, so it would make sense to change permissions and ownership with `sudo chown mysql.root /var/log/mysql/error.log && sudo chmod 640 /var/log/mysql/error.log` – Tubeless Nov 22 '15 at 11:40
3

I had the same issue on Debian 8.5, using MariaDB 10.1.16. I put the configuration as recommended but nothing, there was no way that the error.log file was written with the errors.

At the end, look in / var / log / syslog and there were the errors and warnings

tail -f /var/log/syslog | grep mysql
SergioMC
  • 31
  • 1
1

On systemd linuxes (Ubuntu), it's centralized under systemd which collects and manages kernel and user-land process logs under the journal. To view mariadb journal, run:

# journalctl -u mariadb -f

You should see something along the lines of:

-- Logs begin at Mon 2021-08-30 08:59:29 CDT. --
Aug 25 21:10:22 aorus-15g-yb mysqld[1123]: 2022-08-25 21:10:22 0 [Note] /usr/sbin/mysqld (mysqld 10.3.34-MariaDB-0ubuntu0.20.04.1) starting as process 1123 ...
Aug 25 21:10:22 aorus-15g-yb systemd[1]: Started MariaDB 10.3.34 database server.
Aug 25 21:10:22 aorus-15g-yb /etc/mysql/debian-start[1254]: Looking for 'mysql' as: /usr/bin/mysql
Aug 25 21:10:22 aorus-15g-yb /etc/mysql/debian-start[1254]: Looking for 'mysqlcheck' as: /usr/bin/mysqlcheck
Aug 25 21:10:22 aorus-15g-yb /etc/mysql/debian-start[1254]: This installation of MariaDB is already upgraded to 10.3.34-MariaDB.
Slawomir
  • 147
  • 1
  • 6
0

On Fedora 35, it is located at /var/log/mariadb/mariadb.log. Perhaps for other recent Fedora versions or other distros as well.

MAChitgarha
  • 101
  • 3