Three methods of importing sql files in MySQL


1. Use the tool Navicat for MySQL to import


  • The specific download and usage of the tool recommends an article in the blog garden:

https://www.cnblogs.com/chyf1990/p/12987101.html

1. Open localhost_3306, select and right-click "New Database"

insert image description here

2. Specify the database name and character set (you can choose according to the character set type of the sql file)

insert image description here

3. Select the table under the database to run the SQL file

insert image description here

4. Select the path to import

insert image description here

Second, use the official tool MySQL Workbench to import


1. The first method

①. Create a new database demo (name it whatever you want), click the indicator icon (or Open SQL Script in the File column...)

insert image description here

insert image description here

②. Select the path to import the SQL file

③. Add the command to specify the library name, and click Run

insert image description here

Note: around line 15, 16, if you don't add it, the import will be invalid

PS: No need to save, just delete it after importing, saving will modify the sql file itself;

④. Refresh to view the results

insert image description here

2. The second method


①. Click Import (or Data Import in the Server column)

②. Select the path to import the file

③.Start Import

④. Refresh to view the results

insert image description here

3. Import using the command line

1. Click on the start menu and enter cmd and press Enter to open the dos interface;

r

2.cd into the bin file of the MySQL installation directory;

insert image description here

3. Enter "mysql -u root -p", and then enter the database password;

insert image description here

4.create database Demo to create a new library;

5. Select the database use Demo; select the import path source D:\Demo.sql;

insert image description here

6. View the table show tables;

insert image description here


Summarize

  • All three methods are more applicable, and the first two are recommended for efficiency and convenience.

Guess you like

Origin blog.csdn.net/Elliseaon/article/details/118275142