Mysql command line export and import Database _mysql

Source: Internet
Author: User
Tags import database mysql command line

For example, how to use the command line to implement MySQL export Import database

One, command line export database

1. Into the MySQL directory under the Bin folder: cd MySQL to the Bin folder directory
such as: CD C:\Program files\mysql\mysql Server 4.1\bin
(or add the directory directly to the environment variable path of Windows)

2. Export 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 allow you to enter the password into MySQL)
(If you export a single table, enter the table name after the database name)
3, will see the file News.sql automatically generated to the bin file

Second, the command line to import the database:
1. It is convenient to move the. sql file that you want to import to the bin file.

2. The 1th step derived from the above:
Into the MySQL directory in the bin folder: cd MySQL to the Bin folder directory
such as: CD C:\Program files\mysql\mysql Server 4.1\bin
(or add the directory directly to the environment variable path of Windows)

3. Enter mysql:mysql-u user name-P
As I entered the command line: Mysql-u root-p (Enter the same after will let you enter the MySQL password)

4. Create a new database in Mysql-front that 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;

The above is the entire content of this article, I hope to help you learn, but also hope that we support the cloud habitat community.

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.