c:mydb.sql -u root -p" command. 2. Enter cmd and directly use the "mysqldump -u username -p database name > exported file name" command."/> c:mydb.sql -u root -p" command. 2. Enter cmd and directly use the "mysqldump -u username -p database name > exported file name" command.">

Home  >  Article  >  Database  >  How does MySQL fully export the database?

How does MySQL fully export the database?

anonymity
anonymityOriginal
2019-05-09 14:33:5733956browse

Export method of MySQL database: 1. In the command line, first start the mysql service, and then use the "mysqldump dbname > c:mydb.sql -u root -p" command. 2. Enter cmd and directly use the "mysqldump -u username -p database name > exported file name" command.

How does MySQL fully export the database?

MySQL is a relational database that can store data files. What should we do when we need to export the database?

There are 3 methods provided here:

Method 1:

cmd Go to the mysql bin directory and use the following command

mysqldump --opt -h192.168.0.156 -uusername -ppassword --skip-lock-tables databasename>database.sql

Just change the ip to localhost

If you install navicate, it will be easier. First connect to the database, select the database and then choose to dump sql

Method 2:
Enter cmd (note that it is in os cmd and not in mysql)
================== =
1. Export database (sql script)

mysqldump -u 用户名 -p 数据库名 > 导出的文件名
mysqldump -u root -p db_name > test_db.sql

2.mysql export a table in the database

mysqldump -u 用户名 -p 数据库名 表名> 导出的文件名
mysqldump -u wcnc -p test_db users> test_users.sql (结尾没有分号)

Method three:

Start the mysql service

/etc/init.d/mysql start

Export the entire database

mysqldump dbname > c:mydb.sql -u root -p

Import the database

source mydb.sql
mysql -u用户名 -p 数据库名 < 数据库名.sq

The above is the detailed content of How does MySQL fully export the database?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
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