mysql备份
1语法
mysqldump -h 服务器 -u 用户名 -p密码 数据库名>备份文件。sql
2备份库
mysqldump -uroot -p --database day45> c:\\dey45_bak_2017_10_11.sql
恢复库
mysqldump -uroot -p < c:\\day45_bak_2017_10_11.sql
3备份多个库
mysqldump -uroot -p --databases day43 day44 day45 >c:\\day43_day45_day44_bak_2017_10_11.sql
恢复库
mysql -uroot -p <c:\\day45_bak_2017_10_11.sql
4备份多个表
mysqldump -uroot -p day45 employee t1 t2> c:\\day45_t1_t2_employee_bak_2017_10_11.sql
恢复表
mysql -uroot -p day45 <c:\\day45_t1_t2_employee_bak_2017_10_11.sql
5备份所有的库
mysql -uroot -p --all_databases >c:\\all.sql
恢复库
mysql -uroot -p <c:\\all.sql
6导出表
mysql> SELECT*FROM school.student1
INTO OUTFILE' student1.txt'
FIELDS TERMINATED BY ','//定义字段分隔符
OPTIONALLY ENCLOSED BY' '' ' // 定义字符串使用什么符号括起来
LINES TERMINATED BY '\n' ; //定义换行符
7导入表
mysql>LOAD DATA INFILE '/tmp/student1.txt'
INTO TABLE school.student1
FIELDS TERMINATED BY ','
OPTIONALLY ENCLOSED BY' '' '
LINES TERMINATED BY ' \N';
delimiter $$ #声明存储过程的结束符号为$$
create procedure auto_insert2()
BEGIN
declare i int default 60137;
while(i<300000)do
insert into s1 values(i,'egon','male',concat('egon',i,'@oldboy'));
set i=i+1;
end while;
END$$ #$$结束
delimiter; #重新声明分好为结束符号