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

Mysql database migration and script development

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

Share

Shulou(Shulou.com)06/01 Report--

This article mainly introduces mysql database migration and script development. I hope I can add and update some knowledge to you. If you have any other questions you need to know, you can continue to follow my updated articles in industry information.

The company's new platform is online, and some original user data in the old database need to be migrated to the new platform. This script is specially developed to ensure data integrity and efficiency #! / bin/bash## to the table echo needed in the old database. "Please prepare three files under the scripting language directory, one is tables.txt, which lists the table names that need to be exported from the old database. The other is the user account password and database of the old oldmysqlauth database, and the third is the user account password and database of the new newmysqlauth database, which are listed in the format: 1, 2, 3. "counts= `awk 'BEGIN {twee0 } {tweezers;} END {print t;} 'tables.txt`i = 1mkdir sql if [- e tables.txt] & & [- e oldmysqlauth] & & [- e newmysqlauth]; then while [$I-le $counts]; do table= `awk-v awk_i= "$I"' NR==awk_i {print} 'tables.txt` / usr/bin/mysqldump-u`awk 'NR==1 {print}' oldmysqlauth`-p`awk 'NR==2 {print}' oldmysqlauth``oldmysqlauth``oldmysqlauth` NR==3 {print} 'oldmysqlauth` $table > sql/$table.sql iComple1) done else echo "the program needs incomplete files. Please check that" fiecho "has exported the tables you need from the old database. Data table restore is about to take place "# Import tables exported from the old database into the new database k=1if [- e tables.txt] & & [- e oldmysqlauth] & & [- e newmysqlauth] Thenwhile [$k-le $counts]; do table= `awk-v awk_k= "$k" NR==awk_k {print} 'tables.txt`; / usr/bin/mysql-u`awk' NR==1 {print} 'newmysqlauth`-p`awk' NR==2 {print} 'newmysqlauth` awk' NR==3 {print} 'newmysqlauth` < / root/datapopulate/sql/$table.sql kali$ ((kud1)) done else echo "the program needs incomplete files, please check"

Echo "has migrated the tables from the old database to the new database, thank you for using it!"

Read the above about mysql database migration and script development, hope to give you some help in practical application. Due to the limited space in this article, it is inevitable that there will be deficiencies and need to be supplemented. If you need more professional answers, you can contact us on the official website for 24-hour pre-sales and after-sales to help you answer questions at any time.

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