Home > Database > Mysql Tutorial > How to export data in mysql

How to export data in mysql

(*-*)浩
Release: 2019-06-04 17:52:52
Original
4508 people have browsed it

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

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

Create database

MySQL->USE dbname;
Copy after login

Select database

MySQL->CREATE TABLE tablename;
Copy after login

Create table

MySQL->SHOW DATABASES;
Copy after login

Display database information and those available databases.

MySQL->SHOW TABLES;
Copy after login

Display table information, which tables are available

MySQL->DESCRIBE tablename;
Copy after login

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

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

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

-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!

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
Latest Issues
MySQL stops process
From 1970-01-01 08:00:00
0
0
0
Error when installing mysql on linux
From 1970-01-01 08:00:00
0
0
0
phpstudy cannot start mysql?
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template