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

How to import and export mysql database in Linux

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

Share

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

This article introduces you how to import and export mysql database in Linux, the content is very detailed, interested friends can refer to it, I hope it can help you.

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

1. Export database with mysqldump command

(Note: first cd to mysql run path, and then execute a command):

1. Export data and table structure:

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

Note that my server configuration permissions are special, so I need to use muysqldump -h 127.0.0.1-u username-p password database name> database name you named yourself.sql

mysqldump -uroot -p dbname > dbname .sqlmysqldump -h 127.0.0.1 -uroot -p dbname > dbname .sql

After exporting, you can log in to ftp and find this sql file and download it directly, or download it with scp command.

Enter will prompt for password

2. Export only table structure

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

For example: mysqldump -uroot -p -d dbname > dbname.sql

II. Import database

First, create an empty database.

mysql>create database dbname ;

2. Import database

Method 1:

(1) Select database

mysql>use dbname ; e.g. mysql>use hljz

(2) Set database code

mysql>set names utf8;

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

mysql>source /home/xxxx/dbname .sql; /home/xxxx/dbname.sql is the path of your database file on the server. How to import and export mysql database in Linux is shared here. I hope the above content can be of some help to everyone. You can learn more. If you think the article is good, you can share it so that more people can see it.

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