MySQL command line export and import database
- 2021-01-25 08:02:28
- OfStack
For example, how to use the command line to implement MySQL export import database
1. Command line export database
1. Go to bin under MySQL: cd to bin in MySQL
For example: cd C:\Program Files\MySQL\MySQL Server 4.1\bin
(or add this directory directly to path environment variable windows)
mysqldump -u user name -p database name
>
Export filename
As I input the command line: mysqldump-u root-p news
>
ES38en. ES39en (This will allow you to enter the password to enter ES40en)
Type the table name after the database name if exporting a single table.
3. You will see the file news.sql is automatically generated under bin
SQL > import database from command line
1. The.sql file to be imported should be moved to ES50en file, which is more convenient
2. Step 1 exported from above:
Go to bin under MySQL: cd to bin in MySQL
For example: cd C:\Program Files\MySQL\MySQL Server 4.1\bin
(or simply add this directory to the path environment variable of windows)
3. Enter MySQL: mysql-u User Name -p
mysql-u root-p (the same type will ask you to enter the password of MySQL)
4. Create a new database in MySQL-Front, which is empty. For example, create a target database named news
5. Enter: mysql
>
ES96en target database name
As I type the command line :mysql
>
use news;
6. Import file: mysql
>
source import filename;
As I entered the command line: mysql
>
source news.sql;