mysql database cmd command import and export

Summary of mysql database import and export methods

General form: mysqldump -h IP -u username -p database name> exported file name

(1) Password cannot be added after -p, only input as in 1 (2) mysqldump is a command under cmd, and cannot be under mysql, that is, you cannot enter mysql (that is, under use dpname, you have to exit under mysql) Only possible.)

One: Database export (backup)

0: (Backing up the database means exporting all tables and data without -d)

mysqldump -h localhost -u root -p test > G:\arcgisworkspace\zypdoc\test.sql

mysqldump -h 10.180.6.183 -u root -p dmsdev > D:\imssdb\20170930\dmsdev20170930.sql
mysqldump -h 10.180.6.183 -u root -p newfwk > D:\imssdb\20170930\newfwk20170930.sql
mysqldump -h 10.180.6.183 -u root -p dcsdev > D:\imssdb\20170930\dcsdev20170930.sql

Two: Import (restore) the database

0: Import the database (you have to create data first, then import) C:\Program Files\MySQL\MySQL Server 5.5\bin>

mysql -h localhost -u root -p (enter below mysql)

create database abc; (create database)

show databases; (you can see all existing databases, as well as the database abc just created)

use abc; (Enter the abc database below)

show tables; (see all tables under the abc database, empty)

source G:\arcgisworkspace\zypdoc\test.sql (import database table)

show tables; (check all the tables under the abc database, you can see the tables)

desc pollution; (see table structure design)

select * from pollution;

exit (or ctrl + c) exit mysql

Guess you like

Origin blog.csdn.net/qq_36551486/article/details/82949709