grant lock tables on $database.* to '$user'@'localhost';
# 导入导出数据库的权限
mysqldump -ueisc -p --databases eisc > eisc.sql
# 导出数据库 eisc
mysqldump -ueisc -peisc.cn eisc --tables bbb > eisc.bbb.sql
# 导出从数据库eisc中指定表 bbb
yum -y install holland-mysqldump.noarch # 安装mysqldump导入导出工具
use eisc; SELECT now();DROP TABLE eisc ;create table eisc(id int,name varchar(225),password varchar(255),xingqi varchar(255),city varchar(255));insert into eisc(id,name,password,xingqi,city) values('1','aaa','qqqqq','xingqiyi','ssss'),('2','bbb','qqqqq','xingqier','ddddafweaafe'),('3','ccc','qqqqq','xingqisan','hrgzsaedg');select * from `eisc` ;
# 进入数据库 eisc ; 删除eisc表,创建表,插入表,查询表内容
mysqldump -ueisc -peisc.cn eisc > /root/eisc.sql
将数据库eisc导出为eisc.sql 文件
mysql -ueisc -peisc.cn -e "use eisc;delete from eisc where 'password' ='qqqqq' order by id limit 2;select * from eisc;source /root/eisc.sql;show tables;select * from eisc;"
# 进入数据库eisc,删除表中数据库password是qqqqq的,将id列 排序前两列,
# 查询表,source 导入数据库,列出表查看表。
mysqldump --skip-lock-tables -ueisc -peisccn@eisc eisc --tables bbb > eisc.bbb.sql
怎么避免锁表:在使用参数--skip-opt的时候,忽略了此参数AUTO_INCREMENT,导致恢复后数据没有自增id。
mysqldump --opt -d -ueisc -peisccn@eisc eisc > eisc.bbb.sql
# 不备份任何数据,只导出数据库表结构。