php export and import MySQL database using command line

WBOY
Release: 2016-07-30 13:30:57
Original
1100 people have browsed it

Command line to export the database:
1. Enter the bin folder in the MySQL directory: cd to the bin folder in MySQL
For example, the command line I entered: cd C:Program FilesMySQLMySQL Server 4.1bin
2. Export database: mysqldump -u username -p database name> Exported file name
For example, the command line I entered: mysqldump -u root -p news > news.sql (you will be asked to enter after input Password to enter MySQL)
(If you export a single table, 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


Command line Import the database:
1. Move the .sql file to be imported to the bin file. This path is more convenient.
2. Same as step 1 of the above export.
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 the ySQL password)
4. Create the database you want to build in MySQL-Front. At this time, Empty database, for example, create a new target database named news
5, enter: 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 introduces how to use PHP to export and import MySQL database from the command line, including the relevant content. I hope it will be helpful to friends who are interested in PHP tutorials.

Related labels:
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 admin@php.cn
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!