# 常用姿势

# 1.将数据导出到文本

mysql -h10.10.10.10 -uroot -p123456 -P3306 -Ne "select * from table_name into outfile '/tmp/table_name_result.txt' "
mysql -h10.10.10.10 -uroot -p123456 -P3306 -N < run.sql > /tmp/table_name_result.txt
1
2

# 2.插入或更新数据

insert into class_refund_order_detail (refundds,classid) VALUES (%s,%s) on duplicate key update refundds=values(refundds),classid=values(classid)
1

# 3.查看编码和比较规则

show variables like 'character_%';
show variables like 'collation_%';
1
2

# 4.备份

/usr/bin/mysqldump --single-transaction --quick --lock-tables=true --all-databases | gzip -c > /backup/mysql-$(date +\%F).sql.gz
1

# 5.执行SQL文件

mysql> source xxx.sql
1
更新时间: 12/8/2022, 2:57:16 PM