MySQL Database Import and Export, mysql Database Export
1. Import Database
Enter:
mysql -u username -p test < /home/data/test.sql
Note:
Username is the database user name,
Test is the target database,
/Home/data/test. SQL is the path and name of the Backup
Press enter and enter the Database Password to import the database!
2. Export the database
2.1 export the entire database:
mysqldump -u username -p test > /home/data/test.sql
Note: username is the database username and the test source database. Press enter and enter the Database Password to import the database! The path of the target file is/home/data/
2.2 export a table in the database:
mysqldump -u username -p test documents > /home/data/test.sql
Note: export the documents table in the test database to the target directory.
2.3 export the content of multiple tables to one file:
mysqldump -uroot -t -w "id>627107" test author > add.sql mysqldump -uroot -t -w "id>16943" test agent >> add.sql mysqldump -uroot -t -w "id>3177914" test inventor >> add.sql
Note: If the database has no password, the-p parameter is not required! -W: equivalent to the where clause,-t: Do not write the table creation Information (this table already exists in the target database and does not need to be created again),>: create a new or overwrite existing SQL file, >>: incrementally write existing SQL File