Home > Database > Mysql Tutorial > How to export database in mysql?

How to export database in mysql?

青灯夜游
Release: 2020-09-16 15:15:20
Original
42008 people have browsed it

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
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 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 数据库名 > 导出的文件名
Copy after login

Example:

mysqldump -u root -p db_name > test_db.sql
Copy after login

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

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

Example:

mysqldump -u wcnc -p test_db users> test_users.sql
Copy after login

Note: There is no semicolon at the end

Method 3

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

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!

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