Dino Geek, try to help you

How to enable query logs in MariaDB?


The MariaDB server can write all SQL queries to a file for auditing or debugging purpose. It is called General Query Log. By default, this feature is not enabled.

Here is the process to enable query logs in MariaDB:

Step 1: Open MariaDB Config File
Open your MariaDB configuration file in a text editor. The file’s location may vary depending on the system, but some common locations are /etc/my.cnf or /etc/mysql/my.cnf.

sudo nano /etc/my.cnf

Step 2: Add Settings to the Config File
Scroll to the [mysqld] section in the file and add these settings:

general\_log = on general_log_file = /var/log/mysql/query.log

In the above settings, `general_log = on` enables the general query log, and `general_log_file` sets the path to the log file.

Step 3: Save and Close the File
Use CTRL+X to close the file and then Y to save the changes.

Step 4: Create the Log File

sudo touch /var/log/mysql/query.log

Step 5: Change the Ownership of the Log File

sudo chown mysql:mysql /var/log/mysql/query.log

Step 6: Restart MariaDB Server
Finally, apply these changes by restarting your MariaDB server. The command for this action could be one of the following, depending on your system:

sudo service mariadb restart sudo systemctl restart mariadb sudo service mysql restart sudo systemctl restart mysql

Now, your MariaDB server should log all SQL queries to the specified file. You can view the contents of the log file using a command like cat or tail.

sudo cat /var/log/mysql/query.log

Keep in mind that enabling the general query log may have some performance impact on a busy database server, as it will be writing all queries to a log file.


Simply generate articles to optimize your SEO
Simply generate articles to optimize your SEO





DinoGeek offers simple articles on complex technologies

Would you like to be quoted in this article? It's very simple, contact us at dino@eiki.fr

CSS | NodeJS | DNS | DMARC | MAPI | NNTP | htaccess | PHP | HTTPS | Drupal | WEB3 | LLM | Wordpress | TLD | Domain name | IMAP | TCP | NFT | MariaDB | FTP | Zigbee | NMAP | SNMP | SEO | E-Mail | LXC | HTTP | MangoDB | SFTP | RAG | SSH | HTML | ChatGPT API | OSPF | JavaScript | Docker | OpenVZ | ChatGPT | VPS | ZIMBRA | SPF | UDP | Joomla | IPV6 | BGP | Django | Reactjs | DKIM | VMWare | RSYNC | Python | TFTP | Webdav | FAAS | Apache | IPV4 | LDAP | POP3 | SMTP

| Whispers of love (API) | Déclaration d'Amour |






Legal Notice / General Conditions of Use