- 工信部備案號 滇ICP備05000110號-1
- 滇公安備案 滇53010302000111
- 增值電信業(yè)務(wù)經(jīng)營(yíng)許可證 B1.B2-20181647、滇B1.B2-20190004
- 云南互聯(lián)網(wǎng)協(xié)會(huì )理事單位
- 安全聯(lián)盟認證網(wǎng)站身份V標記
- 域名注冊服務(wù)機構許可:滇D3-20230001
- 代理域名注冊服務(wù)機構:新網(wǎng)數碼
~/.mysql_history文件中記錄每個(gè)用戶(hù)使用數據庫的操作命令
root用戶(hù)的mysql操作,~/.mysql_history
transfor用戶(hù)的mysql操作,/home/transfor/.mysql_history
[root@cp-mysql01-new ~]# tail -20 /root/.mysql_history
show variables like '%resolve%';
show variables like '%connection%';
show global status like ‘Max_used_connections;
show global status like ‘Max_used_connections';
show global status like 'max_user_connections';
show global status like 'max_used_connections';
show global variables like 'max_user_connections';
show global status like '%open%table%';
show variables like 'table%cache%';
show global status like 'thread%';
show variables like 'thread_cache_size';
show global status like 'qcache%';
show variables like 'query_cache%';
select count(id) from mop_bet_order_history;
use lottery;
select count(id) from mop_bet_order_history;
不過(guò)這個(gè)文件會(huì )把所有操作記錄下來(lái),包括創(chuàng )建用戶(hù)和修改用戶(hù)的明文密碼。萬(wàn)一被人攻擊,獲取該文件內容,非常危險。
這個(gè)文件是mysql編譯安裝時(shí)默認配置好的,不容易修改。但是最好不要保存,僅僅刪除是不行的,要直接將其軟連接到垃圾箱:
rm ~/.mysql_history
ln -s /dev/null ~/.mysql_history
如果確實(shí)想將一些操作記錄下來(lái),可以在/etc/my.cnf配置文件的[client]組臨時(shí)添加:
[client]
tee=/tmp/mysql.history
tee命令添加完成后,無(wú)需重啟mysql服務(wù),所以?xún)H對當前打開(kāi)的客戶(hù)端記錄mysql操作命令
等操作使用完成后,注釋
~/.mysql_history文件產(chǎn)生原理
因為mysql本身就是一個(gè)shell,每次mysql連接退出后,都會(huì )把此次操作信息記錄到~/.mysql_history文件中
如果該文件不存在,會(huì )先創(chuàng )建再記錄(像rm,或者剛安裝的mysql)
此文件的名字和路徑,是根據MYSQL_HISTFILE這個(gè)環(huán)境變量來(lái)設置的,默認是~/.mysql_history,修改文件名和路徑:
vim ~/.bash_profile
export MYSQL_HISTFILE=/home/jason/.my_history
./etc/profile重新初始化后,生效
售前咨詢(xún)
售后咨詢(xún)
備案咨詢(xún)
二維碼
TOP