Get the App
SLTechnology News&Howtos  ›  Servers  › 

Ubuntu Command Line Database Import and Export parsing

Shulou Source: shulou.com Published: 2022-06-03 06:37:41 09月24日 Update

The following mainly brings you Ubuntu command line database import export parsing, hope that Ubuntu command line database import export parsing can bring you practical use, this is also my main purpose of editing this article. All right, don't talk too much nonsense, let's just read the following.

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

Some of the more commonly used parameters are:

-p or-- the port of the CVM to which port is connected. If the port of MySQL is not 3306, this parameter is required.

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

-- 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 example's database as an example to do an export example:

1. Export all data (including table structure, including data) from the entire example database

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

two。 Just export the structure of the table

Mysqldump-h 127.0.0.1-u root-p-d-- add-drop-table example > example.sql

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

Connect to MySQL:

Mysql-u root-p

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

CREATE DATABASE example; (database name can be different)

Switch the database:

Use example

Import the specified sql file:

Mysql > source / path/example.sql

For the above Ubuntu command line database import export parsing, we do not think it is very helpful. If you need to know more, please continue to follow our industry information. I'm sure you'll like it.

Tags: Data database commands parameters files structure text content port built no host actual that is commonly used nonsense methods more servers usefulness Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Huawei vpn Microsoft Docker Linux