Get the App
SLTechnology News&Howtos  ›  Database  › 

Mysql database migration and script development

Shulou Source: shulou.com Published: 2022-06-01 20:38:45 10月03日 Update

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.

Tags: Data database script development file user guide password program account question Xinping update check answer three professional company originally available in Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Xiaomi Apple macOS Shulou Technology Linux