CREATE TABLE student (
id INT(10) NOT NULL UNIQUE PRIMARY KEY ,
name VARCHAR(20) NOT NULL ,
sex VARCHAR(4) ,
birth YEAR,
department VARCHAR(20) ,
address VARCHAR(50)
);
CREATE TABLE score (
id INT(10) NOT NULL UNIQUE PRIMARY KEY AUTO_INCREMENT ,
stu_id INT(10) NOT NULL ,
c_name VARCHAR(20) ,
grade INT(10)
);
向student表插入记录的INSERT语句如下:
INSERT INTO student VALUES( 901,'张老大', '男',1985,'计算机系', '北京市海淀区');
INSERT INTO student VALUES( 902,'张老二', '男',1986,'中文系', '北京市昌平区');
INSERT INTO student VALUES( 903,'张三', '女',1990,'中文系', '湖南省永州市');
INSERT INTO student VALUES( 904,'李四', '男',1990,'英语系', '辽宁省阜新市');
INSERT INTO student VALUES( 905,'王五', '女',1991,'英语系', '福建省厦门市');
INSERT INTO student VALUES( 906,'王六', '男',1988,'计算机系', '湖南省衡阳市');
向score表插入记录的INSERT语句如下:
INSERT INTO score VALUES(NULL,901, '计算机',98);
INSERT INTO score VALUES(NULL,901, '英语', 80);
INSERT INTO score VALUES(NULL,902, '计算机',65);
INSERT INTO score VALUES(NULL,902, '中文',88);
INSERT INTO score VALUES(NULL,903, '中文',95);
INSERT INTO score VALUES(NULL,904, '计算机',70);
INSERT INTO score VALUES(NULL,904, '英语',92);
INSERT INTO score VALUES(NULL,905, '英语',94);
INSERT INTO score VALUES(NULL,906, '计算机',90);
INSERT INTO score VALUES(NULL,906, '英语',85);
mysqldump -uroot -p123456 school --set-gtid-purged=OFF | gzip > /backup/school.sql.gz
–set-gtid-purged=OFF
因为在数据库中打开gtid,所以有这个选项
mysqldump -uroot -p123456 -B --all-databases --set-gtid-purged=OFF | gzip > /backup/all.sql.gz
cd /back/data #进入你安装MySQL的数据目录
tar -zcvf /backup/data.tar.gz *
mysqldump -uroot -p123456 school student --set-gtid-purged=OFF > /backup/student.sql
mysqldump -uroot -p123456 -B --databases school db3 --set-gtid-purged=OFF > /backup/dbs.sql
mysqldump -uroot -p123456 -d --set-gtid-purged=OFF --all-databases | gzip > /backup/data.sql.gz
mysqldump -uroot -p123456 -B --all-databases --set-gtid-purged=OFF | gzip > /backup/all.sql.gz
mysql -uroot -p123456
soucre /backup/data.sql
zcat /backup/school.sql.gz | mysql -uroot -p123456
mydumper -u root -p 123456 -B school -o /backup/db0 -S /tmp/mysql.sock
myloader -u root -p 123456 -d /backup/db0 -S /tmp/mysql.sock