Home  >  Article  >  Database  >  How to export data in mysql

How to export data in mysql

(*-*)浩
(*-*)浩Original
2019-05-31 16:23:504432browse

This article mainly introduces the MySQL export sql file, that is, the actual steps of exporting the sql file from the MySQL database.

How to export data in mysql

A brief introduction to how to enter mysql from the command line:

C:\>mysql -h hostname -u username -p

Press the ENTER key, wait and then enter the password, enter the password It is an implicit input, just press the keyboard to input directly, and it will not be fed back to the interface. Here hostname is the name of the server, such as localhost, and username is the MySQL user name, such as root.

After entering the command line, you can directly operate MySQL.

2. Briefly introduce the MySQL commands: (Recommended course study: MySQL video tutorial.)

MySQL->CREATE DATABASE dbname;

Create database

MySQL->USE dbname;

Select database

MySQL->CREATE TABLE tablename;

Create table

MySQL->SHOW DATABASES;

Display database information and those available databases.

MySQL->SHOW TABLES;

Display table information, which tables are available

MySQL->DESCRIBE tablename;

Export database files from the database:

1. Export the database mydb to e: \MySQL\mydb.sql file:

Open Start->Run->Enter cmd to enter command line mode

Note: This is under the command line, not a database command

c:\>MySQLdump -h localhost -u root -p mydb >e:\MySQL\mydb.sql

Note: If access is denied, most of the time cmd needs to be run as administrator

and then enter the password. Wait for a while and the export will be successful. You can check whether it is successful in the target file.

2. Export the mytable in the database mydb to the e:\MySQL\mytable.sql file:

c:\>MySQLdump -h localhost -u root -p mydb mytable>e:\MySQL\mytable.sql

3. Export the structure of the database mydb to e:\MySQL\mydb_stru. In the sql file:

c:\>MySQLdump -h localhost -u root -p mydb --add-drop-table >e:\MySQL\mydb_stru.sql

-h localhost can be omitted, which is generally used on the virtual host

The above is the detailed content of How to export data 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