备份数据库中某张表(本地运行,dos窗口进入mysql的bin目录下,保存后的test.sql文件也在bin目录下)
mysqldump -h localhost -uxxxx -pxxxx database table > test1.sql
可同时备份多个库或多张表
mysqldump -h localhost -uxxxx -pxxxx -- databases database1 database2 database3 > test1.sql
mysqldump -h localhost -uxxxx -pxxxx database table1 table2 table3 > test1.sql
表中部分数据
mysqldump -h localhost -uxxxx -pxxxx database table --where="day < '2019-09-16' and day > '2019-09-10'" > test1.sql
备份并压缩(服务器上运行,保存路径为 /home/ubuntu/test1.sql.gz)
sudo mysqldump -h xxx.xx.xx.xxx -uroot -pxxxxx carl show_popular_logs --where "create_time between '2019-08-11 00:00:00' and '2019-09-15 23:59:59'" | gzip > ~/show_popular_logs_0811-0916.sql.gz
mysqldump -h ip -uxxxx -pxxxx database table | gzip > /home/ubuntu/test1.sql.gz