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

Web Design: Script Materials Reconstruct User Experience

<br />Original text: http://blog.rexsong.com...

Detailed explanation of Nginx static file service configuration and optimization

Root directory and index file The root directive ...

In-depth explanation of nginx location priority

location expression type ~ indicates to perform a...

Three ways to forward linux ssh port

ssh is one of the two command line tools I use mo...

How to change the website accessed by http to https in nginx

Table of contents 1. Background 2. Prerequisites ...

3 functions of toString method in js

Table of contents 1. Three functions of toString ...

mysql 8.0.12 winx64 download and installation tutorial

MySQL 8.0.12 download and installation tutorial f...

WeChat applet custom menu navigation to achieve staircase effect

Design Intentions When developing a page, you oft...

Steps to package and release the Vue project

Table of contents 1. Transition from development ...

CSS achieves the effect of aligning multiple elements at both ends in a box

The arrangement layout of aligning the two ends o...

How to write asynchronous tasks in modern JavaScript

Preface In this article, we'll explore the ev...

Detailed explanation of CSS style cascading rules

CSS style rule syntax style is the basic unit of ...

Steps and pitfalls of upgrading linux mysql5.5 to mysql5.7

Table of contents Linux MySQL 5.5 upgraded to MyS...

Running PostgreSQL in Docker and recommending several connection tools

1 Introduction PostgreSQL is a free software obje...