匯出
mysqldump方法
mysqldump -u使用者名稱 -p密碼名 database [table]> 目標檔案
匯入
mysql -uroot -proot
use database
source 目標檔案;
PS: 這種方法是匯出整個表資料,並且帶著建表資訊,假如匯入的資料庫有同名的表,會被替換
PS: 可以添加條件
mysql -uroot -proot [-n] [-t] [-d] database [table]>name
-t 不包含建立表的資訊
-d不包含資料資訊
--w or -w篩選條件
1 例:先進入dos cmd命令模式 Ctrl旁邊的鍵+R
2 匯出 mysqldump -uroot -proot test student -t -w studentno=10101 >stu
3 匯入 mysql -uroot -proot
4 mysql>use test
5 mysql>source stu
方法二
into outfile
load data infile
例子
匯出
mysql -uroot -proot
mysql>use test
mysql>select * from student where studentno=10101 into outfile './stu';
匯入
mysql -uroot -proot
mysql>use test
mysql>load data infile './stu' into table student;