Home > Database > Mysql Tutorial > How does MySQL fully export the database?

How does MySQL fully export the database?

anonymity
Release: 2020-09-17 09:28:30
Original
34008 people have browsed it

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
Copy after login

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 数据库名 > 导出的文件名
Copy after login
mysqldump -u root -p db_name > test_db.sql
Copy after login

2.mysql export a table in the database

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

Method three:

Start the mysql service

/etc/init.d/mysql start
Copy after login

Export the entire database

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

Import the database

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

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!

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