您好,登錄后才能下訂單哦!
這篇文章主要介紹“mysql查詢?nèi)罩镜拿睢?,在日常操作中,相信很多人在mysql查詢?nèi)罩镜拿顔栴}上存在疑惑,小編查閱了各式資料,整理出簡單好用的操作方法,希望對大家解答”mysql查詢?nèi)罩镜拿睢钡囊苫笥兴鶐椭?!接下來,請跟著小編一起來學習吧!
mysql查詢?nèi)罩臼怯脕碛涗浻脩舻卿洈?shù)據(jù)庫、記錄用戶在數(shù)據(jù)庫操作的日志。類似oracle的審計功能,但是出于線上數(shù)據(jù)庫頻繁的操作,會產(chǎn)生大量的IO和磁盤空間的壓力,mysql是默認關閉的。但是有時候出于安全的考慮需要開啟,這就要在安全和效率之間權衡了。
mysql> show global variables like '%general_log%';
+------------------+----------------------------------------+
| Variable_name | Value |
+------------------+----------------------------------------+
| general_log | OFF | --關閉狀態(tài)
| general_log_file | /data/DB/mysql/trcloud-gtt-test-db.log | --查詢?nèi)罩久Q
+------------------+----------------------------------------+
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 | --開啟狀態(tài)
| general_log_file | /data/DB/mysql/trcloud-gtt-test-db.log | --查詢?nèi)罩久Q
+------------------+----------------------------------------+
現(xiàn)在來看看這些查詢?nèi)罩径加心男┬畔?br/>登錄數(shù)據(jù)庫進行一番操作
[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) --- 登錄失敗
[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; -- 選擇數(shù)據(jù)庫
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; --查詢
+------+------+
| id | name |
+------+------+
| 1 | jx |
+------+------+
1 row in set (0.00 sec)
mysql> drop table emp; -- 刪除
Query OK, 0 rows affected (0.04 sec)
mysql> ^CCtrl-C -- exit! --退出
Aborted
[root@trcloud-wujian-test01 mysql]
打開查詢?nèi)罩?br/>[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 --從哪個IP用什么用戶登錄失敗記錄
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 --記錄從哪個IP哪個用戶何時登錄,191是一個session的唯一表示,同一個session這個數(shù)字是一致的
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 --查詢操作
160412 14:19:40 191 Query drop table emp --刪除操作
160412 14:20:18 191 Quit --退出session
到此,關于“mysql查詢?nèi)罩镜拿睢钡膶W習就結束了,希望能夠解決大家的疑惑。理論與實踐的搭配能更好的幫助大家學習,快去試試吧!若想繼續(xù)學習更多相關知識,請繼續(xù)關注億速云網(wǎng)站,小編會繼續(xù)努力為大家?guī)砀鄬嵱玫奈恼拢?/p>
免責聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉載和分享為主,文章觀點不代表本網(wǎng)站立場,如果涉及侵權請聯(lián)系站長郵箱:is@yisu.com進行舉報,并提供相關證據(jù),一經(jīng)查實,將立刻刪除涉嫌侵權內(nèi)容。