MySQL import SQL database

Source: Internet
Author: User
Tags mysql import
MySQL Import and Export Database
    Blog type:

  • Database
MySQL data structure The basic import/export commands for SQL linux windows databases are mysqldump and Source
In Linux, you can directly use the command line operation. In Windows, there are two methods. One is to use the command line, and the other is to use phpMyAdmin.

The phpMyAdmin tool is easy to export and import. During the import, you do not need to create a database and restore it to the original database. You can use the source tool to restore it. However, the size limit of the imported files cannot exceed 2 MB.

Let's talk about how fast mysqldump and source commands are to be used. But to import the exported files, you must first create a database (This database can be named casually) this step is also required for importing files exported from mysqldump using phpMyAdmin after entering the database.


The following describes how to use the copy command from the predecessors.

1. Export the entire database
Mysqldump-u username-P Database Name> exported file name
Mysqldump-u wcnc-P smgp_rj_wcnc> wcnc. SQL
2. Export a table
Mysqldump-u user name-P database name Table Name> exported file name
Mysqldump-u wcnc-P smgp_rj_wcnc users> wcnc_users. SQL
3. Export a database structure
Mysqldump-u wcnc-p-d -- add-drop-Table smgp_apps_wcnc> D: wcnc_db. SQL
-D no data -- add-drop-table adds a drop table before each create statement.
  
Memo: mysqldump can be directly used in Linux. Sometimes it needs to be used in MySQL/bin in windows, because sometimes commands like appserv can not be used directly because these commands are not in the backup files in the environment variable directory and exported using mysqldump must be created before the database can be imported.



4. Import the database
Common source commands
Go to the MySQL Database Console,
For example, MySQL-u root-P
Mysql> Use Database
Then run the source command. The following parameter is the script file (for example,. SQL used here)
Mysql> source D: wcnc_db. SQL


Suspect: phpMyAdmin has a limited import size. I don't know if there is a limit on the number of source files to be imported, and cannot limit the file size and score files to be exported during export.
Article Source: feino Network (www.firnow.com): http://dev.firnow.com/course/7_databases/mysql/myxl/2008920/144108.html
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.