How to implement import and export mysql database commands under linux

How to implement import and export mysql database commands under linux

1. Export the database using the mysqldump command (note the installation path of mysql, which is the path of this command):

1. Export data and table structure:

mysqldump -u username -p password database name> database name.sql

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

After pressing Enter, you will be prompted to enter a password

2. Export only the table structure

mysqldump -u username -p password -d database name> database name.sql

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

Note: /usr/local/mysql/bin/ —> mysql data directory

2. Import database

1. First create an empty database

mysql>create database abc;

2. Import database

Method 1:

(1) Select a database

mysql>use abc;

(2) Set the database encoding

mysql>set names utf8;

(3) Import data (pay attention to the path of the sql file)

mysql>source /home/abc/abc.sql;

Method 2:

mysql -u username -p password database name < database name.sql

mysql -uabc_f -p abc < abc.sql

The second method is recommended for importing.

Note: There is a command line mode and sql commands

The above method of implementing import and export MySQL database commands under Linux is all the content that the editor shares with you. I hope it can give you a reference. I also hope that you will support 123WORDPRESS.COM.

You may also be interested in:
  • How to use Navicat to export and import mysql database
  • MySQL implements query results export csv file and import csv file into database operation
  • Detailed explanation of MySQL command line export and import database instance
  • How to import and export MySQL database (backup and restore)
  • A brief analysis of the knowledge points of exporting and importing MySQL data

<<:  How to introduce Excel table plug-in into Vue

>>:  Docker implements MariaDB sub-library and sub-table and read-write separation functions

Recommend

Implementation of Nginx Intranet Standalone Reverse Proxy

Table of contents 1 Nginx Installation 2 Configur...

How to set up swap partition SWAP in Linux 7.7

The Swap partition of the Linux system, that is, ...

How to configure the Runner container in Docker

1. Create a runner container mk@mk-pc:~/Desktop$ ...

A few things you need to know about responsive layout

1. Introduction Responsive Web design allows a we...

Recommended tips for web front-end engineers

Let's first talk about the value of web front...

Using MySQL database with Python 3.4 under Windows 7

The detailed process of using MySQL database with...

Writing a rock-paper-scissors game in JavaScript

This article shares the specific code for writing...

Solve the problem of using linuxdeployqt to package Qt programs in Ubuntu

I wrote some Qt interface programs, but found it ...

Nodejs uses readline to prompt for content input example code

Table of contents Preface 1. bat executes js 2. T...

Detailed explanation of the process of installing MySQL on Ubuntu 18.04.4

Let's take a look at the process of installin...

The difference between redundant and duplicate indexes in MySQL

MySQL allows you to create multiple indexes on a ...