MySQL下的安全问题--.mysql_history

本文介绍了在/root目录下发现的.mysql_history文件可能带来的安全隐患,并提供了如何安全地处理该文件的方法,同时提出了一种记录特定mysql操作而不留下长期隐患的方式。

不小心在/root目录下看到一个关于mysql的隐藏文件--.mysql_history,因为以前从没有注意过,遂打开看看是什么玩意。不想到打开吓了一跳,这个文件将我连接mysql的所有操作都记录下来了,包括创建用户及修改用户的明码密码等等。这还了得,万一被人攻击了,那么数据库还不死翘翘了!经查询资料发现这个文件是在编译安装MySQL时默认给配置好的,好像不太容易修改。但是这个文件最好不要保留,否则被人窃取,后果不堪设想。这里仅仅删除是不行的,要直接将其软连接到垃圾箱:

Shell> ln -s /dev/null ~/.mysql_history

那么在进行mysql操作想记录一些操作怎么办?这里如果确实想将操作行为记录下来,则可以在my.cnf文件下的【client】组临时添加tee=/tmp/mysql.history,等操作完成后再将其注释掉。

注意:这个tee命令添加完后,不需要重新启动数据库,所以仅想要对某次的操作做记录配置非常的方便。

mysql_sync_table \ --warehouse hdfs://hdfs-cluster/user/hive/warehouse/ \ --database ods \ --table ods_e_file_load_history_paimon \ --catalog_conf metastore=hive \ --catalog_conf uri=thrift://master-1-1.c-dcd118dc4de41971.us-west-1.emr.aliyuncs.com:9083,thrift://master-1-2.c-dcd118dc4de41971.us-west-1.emr.aliyuncs.com:9083,thrift://master-1-3.c-dcd118dc4de41971.us-west-1.emr.aliyuncs.com:9083 \ --mysql_conf hostname=rm-2ev6m0gj8051dsmm4.mysql.rds.aliyuncs.com \ --mysql_conf port=3306 \ --mysql_conf username=presto \ --mysql_conf password=YxESyMpJMmSG3ZqG \ --mysql_conf database-name=mex_equipment \ --mysql_conf table-name=file_load_history_\d+ \ --primary_keys 'id,device_key' \ # 这里也建议用单引号包裹,避免逗号解析问题 --mysql_conf server-time-zone=America/Bogota \ --mysql_conf scan.startup.mode=earliest-offset \ --table_conf bucket=-1 \ --table_conf changelog-producer=lookup \ --table_conf sink.parallelism=10 \ --table_conf metastore.partitioned-table=true \ --table_conf file.format=parquet \ --metadata_column op_ts \ --ignore_incompatible true \ --table_conf num-sorted-run.stop-trigger=2147483647 \ --table_conf snapshot.time-retained=24h \ --mysql_conf debezium.min.row.count.to.stream.results=50000 \ --mysql_conf debezium.tasks.max=10 \ --mysql_conf debezium.max.queue.size=81920 \ --mysql_conf debezium.max.batch.size=20480 \ --mysql_conf debezium.event.deserialization.failure.handling.mode=skip \ --mysql_conf debezium.binlog.buffer.size=20480 \ --mysql_conf debezium.snapshot.fetch.size=40000 \ --mysql_conf debezium.snapshot.mode=when_needed \ --mysql_conf debezium.table.include.list=mex_equipment.file_load_history_\d+ \ # 核心修正:用单引号包裹 SQL 语句,避免空格被拆分 --mysql_conf debezium.mex_equipment.file_load_history_\d+.query='SELECT * FROM mex_equipment.file_load_history_\d+ WHERE created > "2025-01-01"' \ --type_mapping tinyint1-not-bool,to-nullable \ --mysql_conf scan.incremental.snapshot.enabled=true \ --mysql_conf scan.incremental.snapshot.chunk.size=40000 \ --mysql_conf scan.snapshot.fetch.size=100000 \ --mysql_conf debezium.database.serverTimezone=America/Bogota \ --mode combined \ --mysql_conf server-id=19720-19739 对吗
最新发布
11-20
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值