Mysql Import and Export commands (Linux + Windows), mysql Import and Export

Source: Internet
Author: User
Tags import database mysql import

Mysql Import and Export commands (Linux + Windows), mysql Import and Export
Linux environment:

1. First, check the mysql Data Storage path:Ps-ef | grep mysql

 

  

  

Ii. Enter the mysql Data Storage path found above:Cd var/lib/mysql(Data Storage path)

  

3. Use the mysqldump command to export the database

 

1. Export data and table structure:

Mysqldump-u username-p Database Name> file name. SQL

Example: mysqldump-u root-p database> database00001025. SQL (a prompt is displayed after you press Enter.Enter the password)

2. export only the table structure

Mysqldump-u username-p-d Database Name> database name. SQL

Example: mysqldump-u root-p-d database> database_nodata20171025. SQL

 

Si, import database:

1. Execute SQL statements to create an empty database;

Create database name;

2. Import the database;

Mysql-u username-p database name <database name. SQL

 

Windows Environment

1. First, check the mysql Data Storage path and execute the SQL statement: select concat (@ basedir, 'bin') as datadir from dual

 

Login, enter the system command execution interface (Win + R on the keyboard, Enter cmd), enter the address found on cd +, and press enter to enter the mysql Data Storage path. Example: cd C:/Program Files/MySQL Server 5.5/bin

 

Export and export the database using the mysqldump command:

1. Export data and table structure:

Mysqldump-u username-p Database Name> file name. SQL

Example: mysqldump-u root-p database> database00001025. SQL (enter the password when you press Enter)

2. export only the table structure

Mysqldump-u username-p-d Database Name> database name. SQL

Example: mysqldump-u root-p-d database> database_nodata20171025. SQL

 

Si, import database

1. Execute SQL statements to create an empty Database

Create database name;

2. Import Database

Mysql-u username-p database name <database name. SQL

 

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.