sh ofl导入数据库脚本
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了sh ofl导入数据库脚本相关的知识,希望对你有一定的参考价值。
#! /bin/bash
db_name='ofl_local'
remotedb='https://s3-eu-west-1.amazonaws.com/jbgbackups/ofldotcom/ofldotcom.sql.dump.gz'
cd /var/www/vhosts/oakfurnitureland.com/production/htdocs
wget $remotedb
echo "...Unzip ofl database"
gunzip ofldotcom.sql.dump.gz
mv ofldotcom.sql.dump export.sql
echo "...Remove DB (if exists)"
/usr/bin/mysqladmin -uroot -proot drop $db_name
echo "...Re-add DB"
/usr/bin/mysqladmin -hlocalhost -uroot -proot create $db_name
echo "...Find and replace on database"
sed -i "s|www.oakfurnitureland.com|ofl-local.space48.com|g" ./export.sql
sed -i "s|oakfurnitureland.com|ofl-local.space48.com|g" ./export.sql
echo "...Import production database to local"
/usr/bin/mysql -hlocalhost -uroot -proot $db_name < ./export.sql
echo "...Disabling google analytics"
mysql -u root -proot -e "UPDATE ofl_local.core_config_data SET value='0' WHERE path='google/analytics/active'"
mysql -u root -proot -e "UPDATE ofl_local.core_config_data SET value='0' WHERE path='googletagmanager/googletagmanager/enabled'"
echo "...Clean up files on local"
rm -f export.sql
rm -f ofldotcom.sql.dump
rm -f ofldotcom.sql.dump.gz
以上是关于sh ofl导入数据库脚本的主要内容,如果未能解决你的问题,请参考以下文章
sh 导入MySQL的数据库外壳脚本
shell脚本实现数据库表批量导入记录
Apache Atlas 执行导入hive元数据脚本import-hive.sh报错
脚本导入sql数据
sh bash脚本导入mccity
sh / etc / hosts manager bash脚本(v1.1) - 添加了导入和导出命令!