Import and Export mysql database commands in linux

Source: Internet
Author: User
1. export Database: mysqldump Command 1. export data and table structure: mysqldump-u username-p password database name sqlusrlocalmysqlbinmysqldump-uroot-pabcabcsql. after you press enter, you will be prompted to enter the password. 1. export the database:

Mysqldump command
1. export data and table structure:
Mysqldump-u username-p password database name> database name. SQL
#/Usr/local/mysql/bin/mysqldump-uroot-p abc> abc. SQL
After you press enter, you will be prompted to enter the password

2. export only the table structure
Mysqldump-u username-p password-d database name> database name. SQL
#/Usr/local/mysql/bin/mysqldump-uroot-p-d abc> abc. SQL

Note:/usr/local/mysql/bin/---> mysql data directory

2. import the database:

1. First, create an empty database
Mysql> create database abc;

2. import database
Method 1:
(1) select a database
Mysql> use abc;
(2) Set Database encoding
Mysql> set names utf8;
(3) import data (note the path of the SQL file)
Mysql> source/home/abc. SQL;

Method 2:
Mysql-u username-p password database name <database name. SQL
# Mysql-uabc_f-p abc <abc. SQL

We recommend that you use the second method for import.

Note: the command line mode and SQL command are available.

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.