This shows you the differences between two versions of the page.
mysql_copy_between_servers [2009/04/25 02:43] k2patel |
mysql_copy_between_servers [2020/08/10 02:35] |
||
---|---|---|---|
Line 1: | Line 1: | ||
- | ====== Copy all database between servers ====== | ||
- | NOTE : it not fully written there is many changes needed. | ||
- | |||
- | <code bash | mysql_db_cp.sh> | ||
- | #!/bin/bash | ||
- | |||
- | #----------change following | ||
- | |||
- | #destination username | ||
- | d_User_nm=<username> | ||
- | |||
- | #destination password | ||
- | d_Passwo=<password> | ||
- | |||
- | #source username | ||
- | s_User_nm=<username> | ||
- | |||
- | #source password | ||
- | s_Passwo=<password> | ||
- | |||
- | |||
- | Src_host=<source_server> | ||
- | Dst_host=<Destination_server> | ||
- | db_skp=mysql | ||
- | |||
- | #------------no further | ||
- | |||
- | DBS="$(mysql -h $Src_host --user=$s_User_nm --password=$s_Passwo -Bse 'show databases')" | ||
- | |||
- | for db in ${DBS[@]} | ||
- | do | ||
- | if [ "$db" == "$db_skp" ]; then | ||
- | echo "mysql skipped" | ||
- | else | ||
- | echo "syncing database $db" | ||
- | mysqldump -h $Src_host --user=$s_User_nm --password=$s_Passwo $db | mysql -h $Dst_host -u $d_User_nm -p$d_Passwo -D $db | ||
- | fi | ||
- | done | ||
- | </code> |