Mysql隐藏的风险文件 有两个
1:.mysql_history 文件,记录mysql在主机的所有操作(包括有密码修改等)
2:.mysql_secret 文件,记录初始的root密码
--在安装mysql用户的当前目录下,查看两个文件
[root@hostmysql-m ~]# ll .mysql*
-rw------- 1 root root 33830 Oct 25 11:49 .mysql_history
-rw------- 1 root root 104 Aug 8 14:03 .mysql_secret
--查看.mysql_history 为mysql在主机的所有操作记录
[root@hostmysql-m ~]# tail -10 .mysql_history
exit
use\040flydb;
set\040session\040tx_isolation='REPEATABLE-READ';
update\040test_record_lock_ukindex_table\040set\040score=100\040where\040name='bbb';
commit;
select\040*\040fromtest_record_lock_ukindex_table;
select\040*\040from\040test_record_lock_ukindex_table;
update\040test_nextkey_lock_noindex_table\040set\040score=100\040where\040name='bbb';
select\040*\040from\040test_nextkey_lock_noindex_table;
exit
--查看.mysql_secret 为mysql数据库root用户的初始化密码
[root@hostmysql-m ~]# tail -10 .mysql_secret
# The random password set for the root user at Wed Aug 8 14:03:21 2018 (local time): fN8zc2bEDhhXW4IJ
--清除这两个风险的文件
--清除.mysql_history文件内容 官网:https://dev.mysql.com/doc/refman/5.7/en/mysql-logging.html
[root@hostmysql-m ~]# rm ~/.mysql_history
rm: remove regular file `/root/.mysql_history'? yes
--创建软连接指向空
[root@hostmysql-m ~]# ln -s /dev/null ~/.mysql_history
--查看软连接建立成功
[root@hostmysql-m ~]# ls -al | grep mysql_history
lrwxrwxrwx 1 root root 9 Oct 26 16:30 .mysql_history -> /dev/null
--再次登录时,.mysql_history文件不记录任何记录
[root@hostmysql-m ~]# cat .mysql_history
[root@hostmysql-m ~]#
--清除.mysql_secret文件内容,直接删除即可
[root@hostmysql-m ~]# rm ~/.mysql_secret