admin avatar

mysql定時去重的方法

🕒 by admin

編輯你的mysql.cnf添加如下信息

1
2
3
4
5
[client] 
#password   = your_password 
password    = your passwd 
port        = 3306 
socket      = /tmp/mysql.sock

創建mysql去重腳本,另存爲file.sql文件

1
2
3
4
use dataname;
create table tmp_table as select min(log_ID) from a_post group by a_Title;
delete from a_post where log_ID not in (select * from tmp_table);
DROP TABLE tmp_table;

添加定時任務

1
0 */3 * * *  mysql -uroot  -e "source /路徑/file.sql"

搞定~

💘 相关文章

写一条评论