User Tools

Site Tools


mysql_copy_between_servers

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
mysql_copy_between_servers [2009/04/24 22:40]
k2patel
mysql_copy_between_servers [2009/04/24 22:43] (current)
k2patel
Line 6: Line 6:
 #!/bin/bash #!/bin/bash
  
-User_nm=<​username>​ +#​----------change following 
-Passwo=<​password>​+ 
 +#​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>​ Src_host=<​source_server>​
 Dst_host=<​Destination_server>​ Dst_host=<​Destination_server>​
 db_skp=mysql db_skp=mysql
  
-DBS="​$(mysql -h $Src_host --user=$User_nm ​--password=$Passwo ​-Bse 'show databases'​)"​+#​------------no further 
 + 
 +DBS="​$(mysql -h $Src_host --user=$s_User_nm ​--password=$s_Passwo ​-Bse 'show databases'​)"​
  
 for db in ${DBS[@]} for db in ${DBS[@]}
Line 20: Line 35:
 else else
 echo "​syncing database $db" echo "​syncing database $db"
-mysqldump ​ -h $Src_host --user=$User_nm ​--password=$Passwo ​$db | mysql -h $Dst_host -u root -pk83apuDrug ​-D $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 fi
 done done
 </​code>​ </​code>​
mysql_copy_between_servers.txt · Last modified: 2009/04/24 22:43 by k2patel