Mysql import and export
1. Backup the database: (the command is executed under the mysqlbin directory of DOS)
Mysqldump-- opt school > school.bbb
Note: back up the database school to the school.bbb file. School.bbb is a text file with any file name. Open it and you will find something new.
1. Export the entire database
Mysqldump-u user name-p database name > exported file name
Mysqldump-u root-p aikersql > aiker.sql
two。 Export a table
Mysqldump-u user name-p database name table name > exported file name
Mysqldump-u aiker-p aikersql users > aiker_users.sql
3. Export a database structure
Mysqldump-u root-p-d-- add-drop-table aikersql > d:aiker_db.sql
-d No data-- add-drop-table adds a drop table before each create statement
two。 Import database
Common source commands
Enter the mysql database console, such as mysql-u root-p
Mysql > use database
Then use the source command, followed by a script file (such as .sql used here)
Mysql > source d:aiker_db.sql
You can also use mysql-uroot-p-Ddb1
Transfer the text data to the database
1. The format that the text data should conform to: the field data is separated by tab key, and the null value is replaced by n.
Example:
3 rose Shenzhen No.2 Middle School 1976-10-10
4 mike Shenzhen No.1 Middle School 1975-12-23
2. Data input command load data local infile "file name" into table table name
Note: you'd better copy the files to the mysqlbin directory and type the library where the table is located with the use command first.
[@ more@]