MySQL Database Import and Export, mysql Database Export

Source: Internet
Author: User
Tags import database

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

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.