10. mysql Import and Export Database, mysql Import and Export
Import and Export mysql database commands in linux
1. Use the mysqldump command to export the database
(Note: If this command is not available, run this command in the mysql installation path ):
1. Export data and table structure:
Mysqldump-u username-p Password Database Name> database name. SQL
# Mysqldump-uroot-p abc>/'path'/abc. SQL
Note: After you press enter, you will be prompted to enter the password.
2. export only the table structure
Mysqldump-u username-p password-d Database Name> database name. SQL
# Mysqldump-uroot-p-d abc>/'path'/abc. SQL
Note: After you press enter, you will be prompted to enter the password.
Ii. Import the database 1. First create an empty Database
Mysql> create database abc;
2. Import Database
Method 1:
(1) Select a database
Mysql> use abc;
(2) set database Encoding
Mysql> set names utf8;
(3) import data (note the path of the SQL file)
Mysql> source/home/abc. SQL;
Method 2:
Mysql-u username-p Password Database Name <database name. SQL
# Mysql-uabc_f-p abc <abc. SQL
Note: After you press enter, you will be prompted to enter the password.
Suggestion: you are welcome to give your opinions and suggestions.