MySQL database import Export and modify database name command

Source: Internet
Author: User

Overview

MySQL database import and export, there are two ways

1) pilot out SQL script, then import (import and export are divided into two kinds: 1. Command. 2. Tools. Here we only introduce commands).

2) Copy the database file directly (this method is not recommended).

First, MySQL database import

1. Existing database, you can use the MySQL command directly

Command format

Mysql-u User name-p password database name < SQL file path

Example: mysql-uroot-p12345678 Test </root/test.sql

2. Create a new data import

mysql-uroot-p12345678

mysql> CREATE DATABASE ABC; Delete database command: Drop DB ABC;

mysql> use ABC;

Mysql> Source/root/test.sql

Second, MySQL database export

· Use the mysqldump command (located in the Mysq/bin directory)

Command format

Mysqldump-u User name-p password database name > SQL file path

Example: mysqldump-uroot-p12345678 ABC >/root/abc.sql

Second, MySQL database name modification

This one has a command.

1. Command format

Rename database name to new database name

Note: This command is not supported for all versions of the database

2. Then there's another way: Close the MySQL service, go to the database directory, repair the directory name, and then start MySQL

Personal view: I still do not recommend modifying the database name directly, it is recommended to create a new database and import

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.