当前位置:网站首页>Mysqldump data backup
Mysqldump data backup
2022-07-06 03:13:00 【Rookie ~ ~】
In our last blog, we talked about using mysqlbinlog Tools (mysql Native tools ) Mind parsing a large number of binlog Log files , And use binary logs Data recovery Application practice of , In this blog, let's talk about the command of turning off data backup first , Because we usually work in shell Next , And deployed in the background server or cloud mysql, Most have made some restrictions , We may not be able to connect directly to the database of the background service locally 3306 On port , Generally, there will be intermediate keys of networks such as firewalls , No conditions GUI( GUI tools ) Mouse operation for data backup and so on , Only by command , And the command is also the fastest , So this blog talks about commonly used The data backup , We usually pass mysqldump Conduct .
stay linux shell Execute the following command , You can mytest Library user The data of the table is exported to .sql In file ( Exporting is not just data ,SQL Statements are also exported )
vim user.sql see user.sql The contents of the document are as follows :

Now? mytest Inside the library , We deleted the table , Or we are moving towards data migration , Rebuild this table on another library . We have this sql Script in root Under the root directory , Not enough permissions , It should be executed under ordinary users , So the user.sql Move to ordinary users ( Or we can start with ordinary users mysqldump -u root -p mytest user > ~/user.sql hold mytest Library user The data of the table is exported to .sql In file , There is no need to perform the next steps , Direct execution source /home/admin/user.sql, You can recover user Tables and data )


Now? user.sql yes root The file of , We change a subordinate , So that ordinary users can also operate

And then we source, Is equivalent to .sql Execute the script again 

user The table and data are all recovered , With .sql Script for , Can be in any mysql Rebuild the database table and data on the database
We can also export pure table data directly 
user.txt The contents are as follows :
This way user All the data in the table are exported , We'll use it again python perhaps go When writing some scripts for data analysis , Can pass -t As a separator, get the data of each field for additional data analysis , For example, analyze user behavior , Create user portraits, etc .
mysqldump Data backup command summary
- Export database and table creation SQL
// Export all libraries
mysqldump -u user name -p --all-databases > ~/xxx.sql
// You can export multiple libraries at a time
mysqldump -u user name -p --databases db1[db2] > ~/xxx.sql
// Export the library or a table in the Library
mysqldump -u user name -p dbname [tablename]> ~/xxx.sql
- Export pure data
mysql -u user name -p -D school -e 'select * from user where age>10' > ~/user.txt
- Via backup .sql, Import data , Building database and building tables
Sign in mysql, stay mysql Of shell Execute the following statement on
source ~/school.sql
Or directly at linux Of shell perform
cat ~/data.sql|mysql -u root -p
In this way, the data we backed up before can be sent to mysql In the library table of
边栏推荐
- My C language learning record (blue bridge) -- under the pointer
- codeforces每日5題(均1700)-第六天
- Modeling specifications: naming conventions
- C # create self host webservice
- 华为、H3C、思科命令对比,思维导图形式从基础、交换、路由三大方向介绍【转自微信公众号网络技术联盟站】
- Audio audiorecord binder communication mechanism
- Résumé des méthodes de reconnaissance des caractères ocr
- Self made CA certificate and SSL certificate using OpenSSL
- Computer graduation project asp Net fitness management system VS development SQLSERVER database web structure c programming computer web page source code project
- . Net 6 and Net core learning notes: Important issues of net core
猜你喜欢
![Huawei, H3C, Cisco command comparison, mind map form from the basic, switching, routing three directions [transferred from wechat official account network technology alliance station]](/img/3b/385d19e51340ecd6281df47b39f40c.png)
Huawei, H3C, Cisco command comparison, mind map form from the basic, switching, routing three directions [transferred from wechat official account network technology alliance station]

Era5 reanalysis data download strategy

My C language learning record (blue bridge) -- on the pointer

【若依(ruoyi)】启用迷你导航栏

I sorted out a classic interview question for my job hopping friends

svg拖动点裁剪图片js特效

深入刨析的指针(题解)

ASU & OSU | model based regularized off-line meta reinforcement learning

Research on cooperative control of industrial robots

Jenkins basic knowledge ----- detailed explanation of 03pipeline code
随机推荐
Add one to non negative integers in the array
Redis cache breakdown, cache penetration, cache avalanche
4. File modification
Linear programming matlab
[Li Kou] the second set of the 280 Li Kou weekly match
[ruoyi] enable Mini navigation bar
Overview of OCR character recognition methods
Microservice registration and discovery
原型图设计
1003 emergency (25 points), "DIJ deformation"
Handwriting database client
Polymorphic day02
Tomb. Weekly update of Finance (February 7 - February 13)
Reverse repackaging of wechat applet
1.16 - 校验码
下一个行业风口:NFT 数字藏品,是机遇还是泡沫?
three.js网页背景动画液态js特效
Codeworks 5 questions per day (1700 average) - day 6
svg拖动点裁剪图片js特效
Audio-AudioRecord Binder通信机制