19

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
  • 323

5 Answers5

17

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,730
8

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
  • 217
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
0

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

0

How to locate the MySQL or MariaDB log

1.Login to the server via SSH or Terminal as the root user.

2.Issue the following command: mysql -e "show variables like '%log%';"

3.Locate the option labeled "log_error" to find the path to the log file.

you can view the syslog records related to the MariaDB service with journalctl: $ journalctl -u mariadb.service

If sometime log is not then Open /etc/my.cnf edit log_error=/var/log/mysqld.log. Restart MySQL using the following command. /scripts/restartsrv_msyql.

Vishe
  • 101