How to import and export a MySQL database (backup and restore) _ MySQL

Source: Internet
Author: User
Tags mysql commands mysql command line
This article describes how to import, export, and restore a MySQL database. For more information about MySQL database operations, see the following, it can be divided into two situations: virtual host and server.

Virtual host

1. through PHPMyAdmin's import and export function, this software generally only supports export of several megabytes of data, and too much data may time out.

2. you can use the database backup and restoration function provided by the program. some common PHP programs, such as the DZ Forum, have Database restoration and backup functions in the background, so that we can transfer space data.

3. if your database is purchased in the morning and evening data, our management panel supports one-click backup and restoration. After you click the backup button, you can download the data from the database space through FTP.

Server or VPS

First, we remotely connect to the server (either Windows or Linux) and prepare the root password or the user name and password of the specific database.

I. database import (restoration)

1. source Command

1) Choose start> Program> MySQL Command Line Client and enter the root password of MySQL.

2) then enterUse database name;Enter the corresponding database, and then useThe specific path of the source backup file;Command to import the backup file. Note that the command here must be followed by a semicolon, as shown below:

2. mysql commands

1) in Windows, enter the bin directory of mysql in command line mode, for example, D: \ Program \ mysql41 \ bin. For a Linux system, see the following steps.

2) execute the mysql command to import the database. the command format is:

Mysql-u username-p password database name <备份文件具体路径< p>

For example:Mysql-uroot-pabc123 mydb The user name and password can also be specific to the database, not necessarily root. As follows:

II. database export (backup)

Use the mysqldump command

1) in Windows, enter the bin directory of mysql in command line mode, for example, D: \ Program \ mysql41 \ bin. For a Linux system, see the following steps.

2) execute the mysqldump command to import the database. the command format is:

Mysqldump-u username-p password database name> Specific backup file path

For example:mysqldump -uroot -pabc123 mydb>file.sqlThe user name and password can also be specific to the database, not necessarily root. If the when using lock tables error occurs, add -- skip-lock-tables to the database. As follows:

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.