In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-09 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)06/01 Report--
Preface
The importance of data backup does not need to be overemphasized. In this article, we will use MySQL data to demonstrate how to backup MySQL database by database and table through Shell.
Request
Linux command requirements should be familiar, Shell step syntax rules should also be familiar, and MySQL database backup commands should be familiar. It will also be mentioned below that if you don't know how to learn, you can consult the information and study on your own.
Command window query MySQL database list
Above, we have queried the MySQL database list through the Linux command window.
Remove the MySQL built-in database to get the target business database list and view the table list.
Note: by filtering out MySQL's own database, there is only ckmike database left, and we will back up the library.
There are two tables in the ckmike database, and we can also filter out the first row we don't want from the table list, as follows:
Write steps to backup #! / bash/shUSER=rootPASSWORD=jp349869LOGIN= "mysql-u$USER-p$PASSWORD" DUMP= "mysqldump-u$USER-p$PASSWORD" DATABASE=$ ($LOGIN-e "show databases;" | egrep-v "* schema | mysql | sys" | sed '1d') for database in $DATABASEdo TABLE=$ ($LOGIN-e "use $database) Show tables "| sed '1d') for table in $TABLE do # create [- d / server/back/$database] if the directory does not exist | | mkdir / server/back/$database-p $DUMP $database $table | gzip > / server/backup/$ {database} / ${table} _ $(date +% F) .sql.gz donedone
After saving, perform shell footsteps.
Here Shell step MySQL database sub-database sub-table backup is completed. Linux scheduled tasks can also be written for convenience. I won't talk about how to write scheduled tasks here, but check it out by myself.
Other databases are the same, knowledge commands are different from backup tools, and can be expanded on their own. Finish the job!
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.