2005年01月19日
MySQLでxrea用dump作成手順[ Tips ]
忘れるのでメモ
su mysql
mysql -u root -p mysql
use rizing
※データベースを作成する場合
CREATE TABLE person(
id int(5),
name char(130)
);
CREATE TABLE cd(
id char(6),
name char(20)
);
CREATE TABLE program(
id char(6),
name char(200)
);
CREATE TABLE song(
id char(6),
name char(200)
);
※データベースを削除する場合
DELETE FROM program;
DELETE FROM person;
DELETE FROM song;
DELETE FROM cd;
※/にCSVファイルを置いてから
LOAD DATA INFILE '/program.csv' INTO TABLE `program` FIELDS TERMINATED BY ',' ENCLOSED BY '"' ESCAPED BY '\\' LINES TERMINATED BY '\r\n';
LOAD DATA INFILE '/song.csv' INTO TABLE `song` FIELDS TERMINATED BY ',' ENCLOSED BY '"' ESCAPED BY '\\' LINES TERMINATED BY '\r\n';
LOAD DATA INFILE '/person.csv' INTO TABLE `person` FIELDS TERMINATED BY ',' ENCLOSED BY '"' ESCAPED BY '\\' LINES TERMINATED BY '\r\n';
LOAD DATA INFILE '/cd.csv' INTO TABLE `cd` FIELDS TERMINATED BY ',' ENCLOSED BY '"' ESCAPED BY '\\' LINES TERMINATED BY '\r\n';
mysqldump rizing -uroot -p[rootのパスワード] -Q --opt -rmysql.dump