MySQL Import and export

Source: Internet
Author: User

MySQL command line export database

1. Go to the Bin folder in the MySQL directory: cd MySQL to the Bin folder directory as I entered the command line: CD C:\Program files\mysql\mysql Server 4.1\bin (   Or simply add the Windows environment variable path to the directory) 2, export the database: Mysqldump-u user name-p database name > exported file name as I entered the command line: Mysqldump-u root-p News > News.sql (Input will let you enter MySQL password) (if you export a single table, enter the table name after the database name)

3, you will see the file News.sql automatically generated to the bin file under the command line import database

1, move the. sql file to be imported into the bin file, such a path is more convenient

2, the 1th step with the above export

3, enter mysql:mysql-u user name-p as I entered the command line: Mysql-u root-p (input will also let you enter the MySQL password)

4, create the database you want to build in Mysql-front, this is an empty database, such as a new target database named News

5, Input: Mysql>use target database name as I entered the command line: Mysql>use news;

6, import file: Mysql>source the imported filename, as I entered the command line: Mysql>source news.sql; MySQL backup and restore is done using the mysqldump, MySQL, and source commands.

To back up the database:

Go to CMD to export all databases: input: mysqldump-u [database user name]-p-a>[save path for backup file]

Export data and structure: input: mysqldump-u [Database user name]-p [database name to be backed up]>[backup file save path]

Example: Mysqldump-u root-p test>d:\test.sql Note: This backup backs up only data and structure, no backup stored procedures and triggers

Export-only data structure not exported: input: mysqldump-u [database user name]-p-t [the name of the database to be backed up]>[the save path of the backup file]

Events input in the export database: mysqldump-u [database user name]-p-e [Database user name]>[save path to backup file]

Exporting stored procedures and functions in a database mysqldump-u [database user name]-p-r [Database user name]>[save path to backup file]

Import Database mysql-u root-p<[backup file save path]

Restore Backup files: Enter MySQL Command line Client

Create DATABASE First:

Note: Test is to create the name of the database and then switch to the current database: Use test to enter: \. D:/test.sql or Souce D:/test.sql


Note *****650) this.width=650; "Src=" Https://s1.51cto.com/wyfs02/M02/A4/B3/wKioL1mvxcuC-jstAAANITCZ5Jg670.png-wh_ 500x0-wm_3-wmp_4-s_3992935025.png "title=" Qq20170906173330.png "alt=" wkiol1mvxcuc-jstaaanitcz5jg670.png-wh_50 "/ >


MySQL Import and export

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.