mysql导入导出

导出:
mysqldump -u root -p xxx > xxx.sql --set-gtid-purged=OFF

导出表结构:
mysqldump -u root -p -d --opt xxx > xxx.sql

导入:
mysql -u root -p xxx < xxx.sql


批量导出:
export.sh:
mysqldump -u root -pPWD xxx1 > xxx1.sql
mysqldump -u root -pPWD xxx2 > xxx2.sql
mysqldump -u root -pPWD xxx3 > xxx3.sql

批量导入:
import.sh
mysql -u root -pPWD xxx1 < xxx1.sql
mysql -u root -pPWD xxx2 < xxx2.sql
mysql -u root -pPWD xxx3 < xxx3.sql


1.添加表字段
alter table table1 add f2 varchar(10) not null;
alter table table1 add id int not null auto_increment primary key;

2.修改某个表的字段类型
alter table table1 change f1 f2 int not null;
alter table table1 modify f1 varchar(10) not null;

3.删除某一字段
alter table table1 drop f1;

4.修改表名
alter table table1 rename table2;


1.添加primary key(主键索引)
mysql>alter table `table_name` add primary key (`column`);
2.添加unique(唯一索引)
mysql>alter table `table_name` add unique (`column`);
3.添加index(普通索引)
mysql>alter table `table_name` add index (`column`);
4.添加fulltext(全文索引)
mysql>alter table `table_name` add fulltext (`column`);
5.添加多列索引
mysql>alter table `table_name` add index (`column1`, `column2`, `column3`);