Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

MySQL data export and import instance under Ubuntu command line

2025-01-31 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)05/31 Report--

This article introduces the relevant knowledge of "MySQL data export and import examples under the Ubuntu command line". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!

Mysqldump-h host-u user name-p name > exported database name. sql

Dump-h host-u user name-p database name table name > exported table name .sql

Some of the more commonly used parameters are

-P or-- the server port to which port is connected. This parameter is required if the port of MySQL is not 3306.

-d or-- no-data do not have detailed data, just export the structure of the data

-- when creating a database, add-drop-database first drop the existing database with the same name [usually followed by the-d parameter]

-- when creating a table, add-drop-table first drop the existing table with the same name [usually followed by the-d parameter]

Let's take the database of emlog as an example to do an export example.

one. Export all data (including data structures, including data) from the entire emlog database

Mysqldump-h227.0.0.1-u root-p emlog > emlog_all.sql

two. Export emlog_ blog tables (including table structure and table data)

Mysqldump-h 127.0.0.1-u root-p peerrecom > peerrecom.sql

three. Just export the structure of the database

Mysqldump-h227.0.0.1-uroot-p-d-- add-drop-table emlog > emlog_all_structure.sql

four. Just export the structure of the table

Mysqldump-h227.0.0.1-uroot-p-d-- add-drop-table emlog emlog_blog > emlog_blog_structure.sql

Import, there are many ways, the most simple is the source command, first use the mysql command to connect to the database. Then use source to import the file with the specified path.

Connect to MySQL

Mysql-h227.0.0.1-uroot-p

Create the database first, because there is no statement to create the database in the exported file. If the database has been built, you don't have to create it again.

CREATE DATABASE emlog COLLATE 'utf8_general_ci'

Switch database

Use emlog

Import the specified sql file

Mysql > source / path/.../source.sql

This is the end of the introduction of "MySQL data export and import examples under the Ubuntu command line". Thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report