MySQL Import and Export. SQL File

Source: Internet
Author: User
Tags mysql import

1. MySQL Command Line Mode settings:
Desktop> my computer> Properties> environment variables> New>
Path = "; path \ mysql \ bin;", where path is the installation path of MySQL.
2. A brief introduction to how to access MySQL through the command line:
1. c: \> mysql-H hostname-u username-P
Press enter, and then enter the password. Here, hostname is the name of the server, such as localhost and username is the username of MySQL, such as root.
After entering the command line, you can directly operate MySQL.
2. A brief introduction to the MySQL command:
Mysql-> Create Database dbname; // create a database
Mysql-> Create Table tablename; // create a table
Mysql-> show databases; // displays the database information and available databases.
Mysql-> Use dbname; // select a database
Mysql-> show tables; // displays the table information, available tables
Mysql-> describe tablename; // display the information of the created table
3. Export Database files from the database:
1. Export the database mydb to the E: \ mysql \ mydb. SQL file:
Open start> RUN> Enter cmd to enter Command Line Mode
C: \> mysqldump-H localhost-u root-P mydb> E: \ mysql \ mydb. SQL
Enter the password and wait for a moment until the export is successful. You can check whether the export is successful in the target file.
2. Export mytable in mydb to the E: \ mysql \ mytable. SQL file:
C: \> mysqldump-H localhost-u root-P mydb mytable> E: \ mysql \ mytable. SQL
3. Export the database mydb structure to the E: \ mysql \ mydb_stru. SQL file:
C: \> mysqldump-H localhost-u root-P mydb -- add-drop-Table> E: \ mysql \ mydb_stru. SQL
4. import data from external files to the database:
Import the SQL statements in the file into the database from E: \ mysql \ mydb2. SQL:
1. Enter MySQL from the command line, and then run the create database mydb2 command to create the database mydb2.
2. To exit MySQL, enter the command exit or quit;
3. Enter the following command in cmd:
C: \> mysql-H localhost-u root-P mydb2 <E: \ mysql \ mydb2. SQL
Then enter the password, and then OK.
5. Next, let's talk about how to solve the import file size restriction problem:
By default, MySQL has a limit on the size of the imported file. The maximum size is 2 MB. Therefore, when the file is large, it cannot be imported directly. The following is a solution to this problem:
1. Modify related parameters in PHP. ini:
There are three parameters that affect the size of the MySQL import file:
Memory_limit = 128 M, upload_max_filesize = 2 m, post_max_size = 8 m
Modify upload_max_filesize = 200 M. Modify the size that meets your needs,
You can modify two other memory_limit = 250 m post_max_size = 200 m at the same time.
In this way, the. SQL file below MB can be imported.

 

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.