Skip to navigation
Shell script to batch migrate maria databases from one server to another server
03.08.17
#!/bin/bash USER="root" MYSQL=/usr/bin/mysql MYSQLDUMP=/usr/bin/mysqldump SOURCE_PASSWORD="barbar" SOURCE_HOST="foo.com" TARGET_HOST="localhost" TARGET_PASSWORD="barbar" databases=`$MYSQL --host=$SOURCE_HOST --user=$USER -p$SOURCE_PASSWORD -e "SHOW DATABASES;" | grep -Ev "(Database|information_schema|performance_schema)"` for db in $databases; do echo "Export: $db" $MYSQLDUMP --host=$SOURCE_HOST --force --opt --user=$USER -p$SOURCE_PASSWORD --databases $db > "sql/$db.sql" echo "Import: $db" $MYSQL --force --host=$TARGET_HOST --user=$USER -p$TARGET_PASSWORD $db < "sql/$db.sql" done
https://mariadb.com/kb/en/mariadb/mysqldump/
Reply
Anonymous
Information Epoch 1732664387
Think hierarchically.
Home
Notebook
Contact us