I will give you an example to introduce how to use the command line to implement MySQLExportImport database
1. Command line export database
1. Enter the bin folder in the MySQL directory: cd MySQL to the bin folder directory
For example: cd C:\Program Files\MySQL\MySQL Server 4.1\bin
(Or directly add the directory to the windows environment variable path)
2. Export the database: mysqldump -u username -p database name> exported File name
For example, the command line I entered: mysqldump -u root -p news > news.sql (After entering, you will be asked to enter the password to enter MySQL)
(If you export a leaflet For tables, just enter the table name after the database name)
3. You will see that the file news.sql is automatically generated under the bin file
2. Import the database from the command line:
1. Move the .sql file to be imported to the bin file. This path is more convenient
2. Same as the first step of exporting above:
Enter The bin folder in the MySQL directory: cd to the directory of the bin folder in MySQL
For example: cd C:\Program Files\MySQL\MySQL Server 4.1\bin
(or directly change windows Add the directory to the environment variable path)
3. Enter MySQL: mysql -u username -p
For example, the command line I entered: mysql -u root -p (after entering the same You will be asked to enter your MySQL password)
4. Create a new database you want to build in MySQL-Front. At this time, it is an empty database. For example, create a new target database named news
5 .Input: mysql>use target database name
For example, the command line I entered: mysql>use news;
6.Import file: mysql>source imported file name;
For example, the command line I entered: mysql>source news.sql;
The above is the detailed content of How to export and import database using MySQL command line. For more information, please follow other related articles on the PHP Chinese website!