Home>Article>Database> How to export database in mysql?

How to export database in mysql?

青灯夜游
青灯夜游 Original
2019-05-14 13:37:27 41832browse

How to export the database in mysql? The following article will introduce you to 3 methods of exporting a MySQL database. I hope it will be helpful to you.

How to export database in mysql?

Mysql export database method:

Method 1

cmd to mysql Use the following command in the bin directory:

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 select dump Just sql

Method 2

Enter cmd (note that it is in os cmd and not in mysql), export the database (sql script), basically Syntax:

mysqldump -u 用户名 -p 数据库名 > 导出的文件名

Example:

mysqldump -u root -p db_name > test_db.sql

You can also export only one table in the database. Basic syntax:

mysqldump -u 用户名 -p 数据库名 表名> 导出的文件名

Example:

mysqldump -u wcnc -p test_db users> test_users.sql

Note: There is no semicolon at the end

Method 3

Start the mysql service

/etc/init.d/mysql start

Export the entire database

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

Related learning recommendations:mysql tutorial(video)

The above is the detailed content of How to export database in mysql?. 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