Note: The mysqldump is running under the operating system command line.
Not running under the MySQL command line into the bin folder under the MySQL directory, such as: C:\Program files\mysql\mysql Server 5.5\bin>
Mysqldump-h ip-u user name-p database name > exported file name
(1)-P can not add password, can only be entered as 1 in the same way (2) mysqldump is under the cmd command, no longer MySQL under, that is, can not enter the MySQL (that is, use dpname under, you have to exit MySQL under the exit can be.) )
One: The export of the database
0:mysqldump-h localhost-u root-p Test > G:\arcgisworkspace\zypdoc\test.sql (Back Up database to export all tables and data without-D)
1: (Back up the database to export all table structures)
C:\Program files\mysql\mysql Server 5.5\bin>mysqldump-h localhost-u root-p-D Test > G:\arcgisworkspace\zypdoc\te St.sql
ENTER password:******
2:mysqldump-h localhost-u root-p-D test Pollution > G:\arcgisworkspace\zypdoc\test.sql (the table structure that exports a table does not contain data)
3:mysqldump-h 127.0.0.1-u root-p Test pollution > G:\arcgisworkspace\zypdoc\test.sql (export table structure and data of a table without-D)
0: syntax for backing up multiple databases C:\Program files\mysql\mysql Server 5.5\bin>
Mysqldump-h 127.0.0.1-u root-p--databases Test Bank > G:\arcgisworkspace\zypdoc\test.sql
or mysqldump-h 127.0.0.1-u root-p--databases Test Bank > G:\arcgisworkspace\zypdoc\test.txt is useless because it is still in SQL format.
1: Back up the syntax of all databases C:\Program files\mysql\mysql Server 5.5\bin>
Mysqldump-h 127.0.0.1-u root-p--all-databases > G:\arcgisworkspace\zypdoc\test.sql (temporarily not passed, do not know why)
II: Import of databases
0: Import the database (first to create data, then import) C:\Program files\mysql\mysql Server 5.5\bin>
Mysql-h localhost-u root-p (enter MySQL below)
CREATE DATABASE ABC;
show databases; (You can see all the databases that already exist, and the database ABC you just created)
Use ABC; (enter the ABC database below)
Show tables; (see all the tables below the ABC database, empty)
SOURCE G:\arcgisworkspace\zypdoc\test.sql (Import database table)
Show tables (see all tables below the ABC database to see the table)
desc pollution; (view table structure design)
SELECT * from pollution;
Exit (or CTRL + C) quit MySQL
Three: MySQL How to export text files
0:mysql an external arbitrary file type that is exported as data in the specified format mysql>
Use dbname
Database Changed
SELECT * from pollution into outfile ' g:\\arcgisworkspace\\zypdoc\\text.txt '; (Guide the data, note the escape character OH)
SELECT * from pollution to outfile ' g:\\arcgisworkspace\\zypdoc\\text.csv ' fields TERMINATED by ' \, '; (output format Control)
The result is:
1, auto Exhaust, 200
2, building sand, 180
3, car painting, 160
4, coal, 240
5, others, 80
Knowledge Supplement:
Select [Column name] from TableName [where]
into outfile ' target file path ' [option]
Among the 5 options commonly used in the option parameter
Field TERMINATED by ' string ': Sets the string as the delimiter for the fields, the default value is \ t;
field enclosed by ' character ': sets the string to enclose a character type such as char, varchar text, and the default value is no symbol;
Fields optionally enclosed by ' character ': Sets the value of the field in the string, the default value is no symbol;
LINES starting by ' string ': Sets the character at the beginning of each line, and the default value is no character;
Fields escaped by ' character ': Sets the escape character, the default value is \;
LINES TERMINATED by ' string ': Sets the end of each line, the default value is \ n;
Such as:
SELECT * from pollution to outfile ' g:\\arcgisworkspace\\zypdoc\\text2.csv '
Fields TERMINATED by ' \, ' optionally-enclosed by ' \ '
LINES starting by ' \> ' TERMINATED by ' \ r \ n ';
The result is:
>1, "Auto exhaust", "200"
>2, "Building Yang Sha", "180"
>3, "Car painting", "160"
>4, "Coal", "240"
>5, "Other", "80"
1:mysqldump export Any file type that is external to the data in the specified format C:\Program files\mysql\mysql Server 5.5\bin>
Mysqldump-u root-p-T G:\arcgisworkspace\zypdoc\ ABC pollution "--fields-terminated-by=," (remember not to have any extra spaces or transfer characters;- P also do not write password; Note that the target directory is a folder, the file name is the table name, the suffix is the txt file)
Knowledge Supplement:
Mysqldump-u root-p-T target directory dbname tablename [option]
option and the same as above MySQL, just change to
"--fields-terminated-by= character" (do not have any extra space, that is, fields-terminated-by tightly connected)
MySQL database import and Export method summary (it is time to summarize)