In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)05/31 Report--
This article mainly introduces "the command of mysql query log". In the daily operation, I believe that many people have doubts about the command of mysql query log. The editor consulted all kinds of data and sorted out simple and easy-to-use operation methods. I hope it will be helpful to answer the doubts of "mysql query log command". Next, please follow the editor to study!
The mysql query log is used to record the log of the user logging in the database and the user's operation in the database. Similar to the audit function of oracle, but due to frequent operations of online databases, there will be a lot of pressure on IO and disk space, and mysql is turned off by default. But sometimes it needs to be turned on for security reasons, which requires a tradeoff between security and efficiency.
Mysql > show global variables like'% general_log%'
+-- +
| | Variable_name | Value |
+-- +
| | general_log | OFF |-- disabled status |
| | general_log_file | / data/DB/mysql/trcloud-gtt-test-db.log |-- query log name |
+-- +
2 rows in set (0.00 sec)
Mysql > set global general_log=on
Mysql > show global variables like'% general_log%'
+-- +
| | Variable_name | Value |
+-- +
| | general_log | ON |-- enabled status |
| | general_log_file | / data/DB/mysql/trcloud-gtt-test-db.log |-- query log name |
+-- +
Now let's take a look at the information in these query logs.
Log in to the database to do some operation
[root@trcloud-wujian-test01 mysql] # mysql-P3306-h272.30.249.154-uroot-p
Enter password:
ERROR 1045 (28000): Access denied for user 'root'@'172.30.248.18' (using password: YES)-login failed
[root@trcloud-wujian-test01 mysql] # mysql-P3306-h272.30.249.154-uroot-p
Enter password:
Welcome to the MySQL monitor. Commands end with; or\ g.
Your MySQL connection id is 191
Server version: 5.6.27-76.0-log Percona Server (GPL), Release 76.0, Revision 5498987
Copyright (c) 2009-2015 Percona LLC and/or its affiliates
Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
Affiliates. Other names may be trademarks of their respective
Owners.
Type 'help;' or'\ h' for help. Type'\ c'to clear the current input statement.
Mysql > use test;-- Select a database
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with-A
Database changed
Mysql > select * from emp;-query
+-+ +
| | id | name |
+-+ +
| | 1 | jx |
+-+ +
1 row in set (0.00 sec)
Mysql > drop table emp;-delete
Query OK, 0 rows affected (0.04 sec)
Mysql > ^ CCtrl-C-exit!-exit
Aborted
[root@trcloud-wujian-test01 mysql]
Open query log
[root@trcloud-gtt-test-db mysql] # tail-50f trcloud-gtt-test-db.log
160412 14:18:45 190 Connect root@172.30.248.18 on-logon failure record from which IP with which user
190 Connect Access denied for user 'root'@'172.30.248.18' (using password: YES)
160412 14:19:12 191 Connect root@172.30.248.18 on-record from which IP which user logged in when, 191 is the only representation of a session, the number of the same session is the same
191 Query select @ @ version_comment limit 1
160412 14:19:24 191 Query SELECT DATABASE ()
191 Init DB test
191 Query show databases
191 Query show tables
191 Field List emp
160412 14:19:33 191 Query select * from emp-query operation
160412 14:19:40 191 Query drop table emp-delete operation
160412 14:20:18 191 Quit-exit session
At this point, the study of "mysql query log command" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un