• Categories
    Category
    {{ postCtrl.tags }}
    • {{ category.tag_type }}

      • {{tag.tag_name}}
      • View more
  • Categories
    Category
    {{ postCtrl.tags }}
    • {{ category.tag_type }}

      • {{tag.tag_name}}
      • View more
  • News
  • Tutorials
  • Forums
  • Tags
  • Users
Tutorial News Comments FAQ Related Articles

How to Enable MariaDB Slow Query Log and Change the Long Query Time on CentOS 7.6

  • 00:36 mysql -u root -p
  • 00:54 SET GLOBAL slow_query_log='ON';
  • 01:13 SET GLOBAL long_query_time=6;
  • 01:25 cd /var/lib/mysql
  • 01:28 ls -la
  • 01:43 SET GLOBAL slow_query_log = 'OFF';
{{postValue.id}}

How To Enable the Slow Query log, Change the Long Query time for MariaDB database On CentOS 7.6

Procedure

Login to the MariaDB database using the root password as follows

[root@linuxhelp ~]# mysql -u root -p
Enter password: 
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 3
Server version: 5.5.60-MariaDB MariaDB Server

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [(none)]> SET GLOBAL slow_query_log='ON';
Query OK, 0 rows affected (0.00 sec)

MariaDB [(none)]> SET GLOBAL long_query_time=6;
Query OK, 0 rows affected (0.00 sec)

MariaDB [(none)]> exit
Bye

After enabling the Slow query log and setting the long query time,navigate to the file location of the slow query log

[root@linuxhelp ~]# cd /var/lib/mysql

List the directories in the mysql directory to check the slow query log

[root@linuxhelp mysql]# ls -la
total 28708
drwxr-xr-x   4 mysql mysql      191 Aug  3 10:18 .
drwxr-xr-x. 65 root  root      4096 Apr 15 11:09 ..
-rw-rw----   1 mysql mysql    16384 Aug  3 10:08 aria_log.00000001
-rw-rw----   1 mysql mysql       52 Aug  3 10:08 aria_log_control
-rw-rw----   1 mysql mysql 18874368 Aug  3 10:08 ibdata1
-rw-rw----   1 mysql mysql  5242880 Aug  3 10:09 ib_logfile0
-rw-rw----   1 mysql mysql  5242880 Apr 15 10:44 ib_logfile1
-rw-rw----   1 mysql mysql      176 Aug  3 10:18 linuxhelp-slow.log
drwx------   2 mysql mysql     4096 Apr 15 10:44 mysql
srwxrwxrwx   1 mysql mysql        0 Aug  3 10:09 mysql.sock
drwx------   2 mysql mysql     4096 Apr 15 10:44 performance_schema

Login to the MariaDB database to disable the slow query log as follows

 
[root@linuxhelp mysql]# mysql -u root -p
Enter password: 
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 5
Server version: 5.5.60-MariaDB MariaDB Server

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [(none)]> SET GLOBAL slow_query_log = 'OFF';
Query OK, 0 rows affected (0.00 sec)

MariaDB [(none)]> exit
Bye

With this, Slow query log has been successfully enabled , set the time interval for the execution of the query and disabled it successfully for MariaDB On CentOS 7.6

Tags:
alexander
Author: 

Comments ( 0 )

No comments available

Add a comment
{{postCtrl.cmtErrMsg}}

Frequently asked questions ( 5 )

Q

What is slow query log?

A

Slow Query log is a feature in MYSQL which records the SQL statements(queries) that exceeds A SET LONG QUERY time.

Q

What is the default location of the Slow Query log file?

A

The default Location of Slow Query log is /var/lib/mysql/

Q

How does MYSQL create a name to Slow Query log?

A

MYSQL creates SLow query log with a hostname.

Q

How to enable the Slow Query Log?

A

To enable the Slow Query log in MYSQL thorugh command is " SET GLOBAL slow_query_log="ON"

Q

Does this feature gets enabled by default in MYSQL?

A

No, this feature gets disabled by default as it weakens the server performance.

Back To Top!
Rank
User
Points

Top Contributers

userNamenaveelansari
135850

Top Contributers

userNameayanbhatti
92510

Top Contributers

userNamehamzaahmed
32150

Top Contributers

1
userNamelinuxhelp
31040

Top Contributers

userNamemuhammadali
24500
Can you help Ganesh Konka ?
Zentya 6.1 http proxy configuration

please send link for creating zentyal 6.1 for http proxy and firewall as gateway.

Networking
  • Routing
  • trunk
  • Netmask
  • Packet Capture
  • domain
  • HTTP Proxy
Server Setup
  • NFS
  • KVM
  • Memory
  • Sendmail
  • WebDAV
  • LXC
Shell Commands
  • Cloud commander
  • Command line archive tools
  • last command
  • Shell
  • terminal
  • Throttle
Desktop Application
  • Linux app
  • Pithos
  • Retrospect
  • Scribe
  • TortoiseHg
  • 4Images
Monitoring Tool
  • Monit
  • Apache Server Monitoring
  • EtherApe 
  • Arpwatch Tool
  • Auditd
  • Barman
Web Application
  • Nutch
  • Amazon VPC
  • FarmWarDeployer
  • Rukovoditel
  • Mirror site
  • Chef
Contact Us | Terms of Use| Privacy Policy| Disclaimer
© 2025 LinuxHelp.com All rights reserved. Linux™ is the registered trademark of Linus Torvalds. This site is not affiliated with linus torvalds in any way.