Import the exported database file through the MySQL command line statement

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

Today, a classmate asked me if I can transfer the database, I thought that should be a new table, but that efficiency is too low, and also need to import a lot of records in the table, trouble, so think of MySQL bin in two instructions, mysqldump and resource.

MySQL command line export database:

1. First we go through the command line to the MySQL installation directory of the bin directory, such as I entered the command behavior: CD c:program filesmysqlmysql Server 5.5bin

(If the Win7 system, and MySQL installed in the C disk directory, if the instructions above to deny access, it is the administrator's way to run the command prompt on the line)

2. Export database: Mysqldump-u user name-p database name > exported file name

As I entered the command line: mysqldump-u root-p ATM > Atm.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. After executing the above command, we can see the Atm.sql database file we just exported in the bin directory, which contains all the tables in the database and the records in the table.

MySQL command line Import Database:

1. First of all, we will import the. sql file into the database into the bin directory, which is more convenient.

2. Then we enter the MySQL Command line Client, enter the password, go to "mysql>", create a new database (Mysql>create DB test;)

3. Use the newly created database Mysql>use test;

4. import file: Mysql>source the imported filename; For example, I want to import the Atm.sql data file I just exported: Mysql>source atm.sql;

5. If there is no hint of error message, we can use show tables to see that the newly created test database has already imported the contents of the new ATM database.

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.