Step 5 for MySQL to import SQL files _ MySQL

Source: Internet
Author: User
Tags mysql import
Five major steps for MySQL to import SQL files: bitsCN.com

The following articles mainly introduce how to import and export SQL files from MySQL databases, that is, how to import and export SQL files from MySQL databases. We will mainly divide these files into five major steps to describe them, if you are interested, you can click the following articles to view them.
The procedure is as follows:
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 database
MySQL-> show tables;
Displays table information. available tables
MySQL-> DESCRIBE tablename;
Displays information about 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
-H localhost can be omitted, which is generally used on a VM.
4. import data from the external file MySQL 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, the size of the MySQL imported file is limited to 2 MB. Therefore, when the file is large, it cannot be imported directly. the solution to this problem is as follows:
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 _......

This article is from "Zuo Luo CTO"

BitsCN.com

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.