In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-05 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)05/31 Report--
This article is about what the Mysql database export and import sql database file commands are. The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.
When using a MySQL database, you often need to back up and restore the database, and it is very convenient to export sql file backup and directly perform sql file recovery.
How to export and import sql files from a MySQL database through the cmd command?
Export 1. Export database
Contains data objects and data
Mysqldump-hhostname-uusername-ppassword databasename > / home/justin/databasename.sql II. Export database table structure
Only database table structure
Mysqldump-hhostname-uusername-ppassword-d databasename > / home/justin/databasename.sql III. Export stored procedures and functions
1. Query stored procedures and functions in the database
Method 1:
Select `name` from mysql.proc where db = 'databasename' and `type` =' PROCEDURE';-- stored procedure select `name` from mysql.proc where db = 'databasename' and `type` =' FUNCTION';-- function
Method 2:
Show procedure status;show function status
2. Mysql export stored procedures and functions
Mysqldump-hhostname-uusername-ppassword-ntd-R databasename > / home/justin/prorandfunc.sql parameter description-d structure (--no-data: no data is exported, only database table structure is exported)-t data (--no-create-info: only data is exported without adding CREATE TABLE statements)-n (--no-create-db: only data is exported Instead of adding CREATE DATABASE statements)-R (--routines: export stored procedures and custom functions)-E (--events: export events)-- triggers (default export trigger, using-- skip-triggers masking export)-B (--databases: export database list Single library can be omitted)-tables table list (single table can be omitted) when ① exports structure and data at the same time,-d and-t ② can be omitted and no structure and data can be exported at the same time.-ntd ③ can only export stored procedures and functions. All (structure & data & stored procedures & functions & events & triggers) can be exported using-R-E (equivalent to ①, omitting-d-t). ⑤ only exports structures & functions & events & triggers import using-R-E-d
1. First build an empty database
Mysql > create database test
2. Import the database
Method 1:
(1) Select a database
Mysql > use test
(2) set database coding
Mysql > set names utf8
(3) Import data (note the path of the sql file)
Mysql > source / home/justin/test.sql
Method 2:
Mysql-hhostname-uusername-ppassword abc < / home/justin/test.sql; Thank you for reading! On "Mysql database export and import sql database file command is what" this article is shared here, I hope the above content can be of some help to you, so that you can learn more knowledge, if you think the article is good, you can share it out for more people to 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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.