Get the App
SLTechnology News&Howtos  ›  Database  › 

How to export and import .sql files in linux

Shulou Source: shulou.com Published: 2022-05-31 22:31:13 11月10日 Update

This article shows you how to export and import .sql files in linux, the content is concise and easy to understand, it will definitely brighten your eyes. I hope you can get something through the detailed introduction of this article.

What is Linux system Linux is a free-to-use and free-spread UNIX-like operating system, is a POSIX-based multi-user, multi-task, multi-threaded and multi-CPU operating system, using Linux can run major Unix tools, applications and network protocols.

1. Export the database using the mysqldump command (pay attention to the installation path of mysql, that is, the path of this command):

1. Export data and table structure:

Mysqldump-u user name-p password database name > database name. Sql

# / usr/local/mysql/bin/ mysqldump-uroot-p abc > abc.sql

When you hit enter, you will be prompted to enter the password.

2. Export only the table structure

Mysqldump-u user name-p password-d database name > database name. Sql

# / usr/local/mysql/bin/ mysqldump-uroot-p-d abc > abc.sql

Note: / usr/local/mysql/bin/-> data directory of mysql

Second, import the database

1. First build an empty database

Mysql > create database abc

2. Import the database

Method 1:

(1) Select a database

Mysql > use abc

(2) set database coding

Mysql > set names utf8

(3) Import data (note the path of the sql file)

Mysql > source / home/abc/abc.sql

Method 2:

Mysql-u user name-p password database name < database name. sql

# mysql-uabc_f-p abc < abc.sql the above is how to export and import .sql files in linux. Have you learned any knowledge or skills? If you want to learn more skills or enrich your knowledge reserve, you are welcome to follow the industry information channel.

Tags: Data database password user file user name system path guide operating system content command skill method knowledge structure concise free concise task Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno vpn Shulou Tech Info Xiaomi macOS MySQL