How to Add MariaDB Error Log File on CentOS 7/8
Hello server administrator, in this article I’m going to share how to create MariaBD error log flie on CentOS. I’m testing on CentOS 8. Let’s start:
Table of Contents
Check Log File
We can see log file in my.cnf
file like:
cat /etc/my.cnf
We can also find log file using:
# login to mysql
mysql -u root -p
# now see log file location
show variables like '%log_erro%';
If you see like below image, you need to create error log file:
MariaDB [(none)]> show variables like '%log_erro%';
+---------------+-------+
| Variable_name | Value |
+---------------+-------+
| log_error | |
+---------------+-------+
Create Log File
Open my.cnf
file and add this code:
[mysqld_safe]
log_error=/var/log/mariadb/error.log
[mysqld]
log_error=/var/log/mariadb/error.log
After that, restart mariadb service:
systemctl restart maridb
Now try to find error log file:
# login to mysql
mysql -u root -p
# now see log file location
show variables like '%log_erro%';
Output:
MariaDB [(none)]> show variables like '%log_erro%';
+---------------+----------------------------+
| Variable_name | Value |
+---------------+----------------------------+
| log_error | /var/log/mariadb/error.log |
+---------------+----------------------------+
See Error Logs & Reset
We’ve added error log file. Now let’s check error logs by using this command:
sudo tail -f /var/log/mariadb/error.log
Great..! We’re seeing error logs of MariaDB. To reset or make the log file empty, just run this command:
sudo truncate -s 0 /var/log/mariadb/error.log
That’s it. Thanks for reading. ?
Comment
Preview may take a few seconds to load.
Markdown Basics
Below you will find some common used markdown syntax. For a deeper dive in Markdown check out this Cheat Sheet
Bold & Italic
Italics *asterisks*
Bold **double asterisks**
Code
Inline Code
`backtick`Code Block```
Three back ticks and then enter your code blocks here.
```
Headers
# This is a Heading 1
## This is a Heading 2
### This is a Heading 3
Quotes
> type a greater than sign and start typing your quote.
Links
You can add links by adding text inside of [] and the link inside of (), like so:
Lists
To add a numbered list you can simply start with a number and a ., like so:
1. The first item in my list
For an unordered list, you can add a dash -, like so:
- The start of my list
Images
You can add images by selecting the image icon, which will upload and add an image to the editor, or you can manually add the image by adding an exclamation !, followed by the alt text inside of [], and the image URL inside of (), like so:
Dividers
To add a divider you can add three dashes or three asterisks:
--- or ***

Comments (0)