Home > Database > Mysql Tutorial > body text

How to export and import database using MySQL command line

怪我咯
Release: 2017-03-30 11:26:30
Original
1558 people have browsed it

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!

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact [email protected]
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!