Overview
There are two ways to import and export mysql Databases
1) Export the SQL script first and then import it (there are two types of Import and Export: 1. commands. 2. Tools. Here we only introduce commands ).
2) directly copy database files (this method is not recommended ).
I. mysql Database Import
1. You can use the mysql command to create an existing database.
Command Format
Mysql-u username-p Password Database Name <SQL file path
Example: mysql-uroot-p12345678 test </root/test. SQL
2. Create new data import
Mysql-uroot-p12345678
Mysql> create database abc; // command for deleting a database: drop database abc;
Mysql> use abc;
Mysql> source/root/test. SQL
Ii. mysql Database Export
· Use the mysqldump command (in the mysq/bin directory)
Command Format
Mysqldump-u username-p Password Database Name> SQL file path
Example: mysqldump-uroot-p12345678 abc>/root/abc. SQL
Ii. Modify the mysql database name
This has a command
1. Command Format
Rename database old database name to new database name
Note: not all versions of databases support this command.
2. There is another way: Close the mysql service, enter the database storage directory, repair the directory name, and then start mysql.
My opinion: I still do not recommend modifying the database name directly. We recommend that you create a database and import it again.