redis导数到mysql

时间:2022-02-07 05:08:55

filename=$(date "+%Y%m%d%H%M%S")

//将type为list,键为bi0205导出文本,并保存到mysql导入导出目录
redis-cli -h 服务器IP -p port -a username@password "bi0205" 1 10000000 >>/var/lib/mysql-files/loginfo_$filename.txt

//将导出的文件导入mysql
mysql -uroot -ppasword -e "load data infile \"/var/lib/mysql-files/loginfo_$filename.txt\" into table dbname.loginfo_1;"

//根据需要进行处理
mysql -uroot -ppassword -e "call dbname.elt_loginfo()"

//删除从redis导出的数据文件
rm /var/lib/mysql-files/loginfo_$filename.txt