Import and export methods of mysql database under liunx

1. Import of mysql data
1. Use Xshell and other tools to connect to the liunx server and enter

mysql -uroot -p

Press Enter and we are prompted to enter the root password. After entering the password, we enter mysql.
2. Check which databases are available. It is not necessary.

show databases;

3. Select the database you want to import data into

use abc;

abc is the name of the database.
4. Set the database encoding, which is not necessary.

et names utf8;

5. Import database

source /home/abc/abc.sql;

Pay attention to the path of the sql file you uploaded.

2. Export of mysql database
1. Export all data in the entire database

mysqldump -u userName -p  dabaseName  > fileName.sql

fileName.sql needs to add the path

2. Export data from a table in the database

mysqldump -u userName -p  dabaseName tableName > fileName.sql 

3. Export all table structures in the entire database

mysqldump -u userName -p -d dabaseName  > fileName.sql

Note: -d is added

4. Export the table structure of a table in the entire database

mysqldump -u userName -p -d dabaseName tableName > fileName.sql

Note: -d is added

Guess you like

Origin blog.csdn.net/likeni1314/article/details/108308123