Mysql Import and Export SQL files (including database and data table operations), mysql Import and Export
Let's just get started.
Log on to mysql under the windows command line, create a database test_01, create a user table, and insert a piece of data, as shown below:
1. Export the database test_01
1. log out of the database and enter
Mysqldump -- no-defaults-u root-p test_01> d: \ test01. SQL (without a colon, press enter directly)
2. Enter the password
Note: The command line must be in the system,
-- No-defaults cannot be saved (the reason is unknown ),
Test_01 is the source database, 01. SQL is the target database
Result: The 01. SQL file is displayed in d: \ test.
2. Export the data table user in the database test_01
Command: mysqldump -- no-defaults-u root-p test_01 user> d: \ test \ user. SQL
Result: The user. SQL file is displayed in d: \ test.
3. Import the user table to the database test_01
First, log on to the database and delete the user table drop table user;
Then, if you have selected the test_01 database, enter the command source d: \ test \ user. SQL.
And then it succeeds.
4. Import the database (01. SQL)
First, delete the database test_01,
Drop database test_01;
Then create a database, such as test_01 (previously deleted to better import ^_^)
Create database test_01;
Select test_01 use test_01
Enter source d: \ 01. SQL
Show tables;
Successful!
These are my most convenient and common import and export operations. Thank you for your criticism!