Mysql Database Import and Export and modify Database Name commands

Source: Internet
Author: User

Overview

There are two ways to import and export mysql Databases

1) Export the SQL script first and then import it (there are two types of Import and Export: 1. commands. 2. Tools. Here we only introduce commands ).

2) directly copy database files (this method is not recommended ).

I. mysql Database Import

1. You can use the mysql command to create an existing database.

Command Format

Mysql-u username-p Password Database Name <SQL file path

Example: mysql-uroot-p12345678 test </root/test. SQL

2. Create new data import

Mysql-uroot-p12345678

Mysql> create database abc; // command for deleting a database: drop database abc;

Mysql> use abc;

Mysql> source/root/test. SQL

Ii. mysql Database Export

· Use the mysqldump command (in the mysq/bin directory)

Command Format

Mysqldump-u username-p Password Database Name> SQL file path

Example: mysqldump-uroot-p12345678 abc>/root/abc. SQL

Ii. Modify the mysql database name

This has a command

1. Command Format

Rename database old database name to new database name

Note: not all versions of databases support this command.

2. There is another way: Close the mysql service, enter the database storage directory, repair the directory name, and then start mysql.

My opinion: I still do not recommend modifying the database name directly. We recommend that you create a database and import it again.

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.