MYSQL Import export sql file brief analysis

  • 2021-01-03 21:07:09
  • OfStack

1.MYSQL's command line mode Settings

Desktop - > My computer > Property - > Environment variable - > New - >
PATH = "; path \ mysql \ bin;" path is the installation path of MYSQL.

2. Command line access to MYSQL method

1.C:\ > mysql -h hostname -u username -p
Press ENTER, wait, 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.
You can work with MYSQL directly from the command line.
2. Brief introduction 1 MYSQL command:


  mysql->CREATE DATABASE dbname;// Creating a database 
  mysql->CREATE TABLE tablename;// Create a table 
  mysql->SHOW DATABASES;// Displays database information, which databases are available. 
 mysql->USE dbname;// Select database 
  mysql->SHOW TABLES;// Displays table information, which tables are available 
  mysql->DESCRIBE tablename;// Displays information about the table that was created 

3. Database export database file

1. Export database mydb to e:\mysql\ mydb.sql file:
Open start - > Run - > Enter cmd for command line mode
c:\ > mysqldump -h localhost -u root -p mydb > e:\mysql\mydb.sql
Then enter the password, wait for 1 will be exported successfully, you can go to the target file to check whether the success.
2. Export mytable from database mydb to e:\mysql\ mytable.sql file:
c:\ > mysqldump -h localhost -u root -p mydb mytable > e:\mysql\mytable.sql
3. Export the structure of database mydb to the file e:\mysql\ mydb_stru.sql:
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 from the file into the database from e:\mysql\ mydb2.sql:
1. Enter mysql from the command line, then use the command CREATE DATABASE mydb2; Create the database mydb2.
2. Exit mysql and 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, OK.

5. Solve the problem of import file size limitation

By default: mysql has a limit on the size of the imported file, the maximum size is 2M, so when the file is too large, it cannot be imported directly. The following are the solutions to this problem:
1. Modify relevant parameters in ES122en. 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

Change upload_max_filesize=200 M here change the size to suit your needs,
The other two items, memory_limit=250M post_max_size=200M, can be modified simultaneously
This allows you to import.sql files below 200M.

Above is about MYSQL import and export.sql file details, hope to help you learn.


Related articles: