Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to import sql files in MySQL

2025-04-06 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)05/31 Report--

How to import sql files in MySQL, I believe that many inexperienced people are at a loss about this. Therefore, this paper summarizes the causes and solutions of the problem. Through this article, I hope you can solve this problem.

The steps are as follows:

I. setting the command line mode of MySQL:

Desktop-> my computer-> Properties-> Environment variables-> New->

PATH= "; path\ MySQL\ bin;" where path is the installation path of MySQL.

two。 Briefly introduce how to enter MySQL on the command line:

1.C:\ > MySQL-h hostname-u username-p

Press enter, wait and enter the password. Where hostname is the name of the server, such as localhost,username is the user name of MySQL, such as root.

After entering the command line, you can directly manipulate MySQL.

two。 A brief introduction to the MySQL command:

MySQL- > CREATE DATABASE dbname

Create a database

MySQL- > CREATE TABLE tablename

Create a tabl

MySQL- > SHOW DATABASES

Displays database information about which databases are available.

MySQL- > USE dbname

Select a database

MySQL- > SHOW TABLES

Displays table information, which tables are available

MySQL- > DESCRIBE tablename

Displays information about the created table

three。 Export the database file 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

Then enter the password and wait for a while for the export to be successful. You can check whether it is successful in the target file.

two。 Export the mytable from the database mydb to the e:\ MySQL\ mytable.sql file:

C:\ > MySQLdump-h localhost-u root-p mydb mytable > e:\ MySQL\ mytable.sql

3. Export the structure of the database mydb 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 and is generally used on the

four。 Import data into the database from the external file MySQL:

Import the SQL statement from the file into the database from e:\ MySQL\ mydb2.sql:

1. Enter MySQL from the command line and create the database mydb2 with the command CREATE DATABASE mydb2;.

two。 You can enter the command exit; or quit to exit MySQL

3. Enter the following command in CMD:

C:\ > MySQL-h localhost-u root-p mydb2 < e:\ MySQL\ mydb2.sql

Then enter the password and OK it.

five。 Let's talk about how to solve the problem of import file size limit:

By default: MySQL imports files with a maximum size of 2m, so when the file is very large, it cannot be imported directly. The solution to this problem is listed below:

1. Modify the relevant parameters in .ini:

There are three parameters that affect the size of the MySQL import file:

Memory_limit=128M,upload_max_filesize=2M,post_max_size=8M

Modify upload_.

After reading the above, have you mastered the method of how to import sql files in MySQL? If you want to learn more skills or want to know more about it, you are welcome to follow the industry information channel, thank you for reading!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report