-
Notifications
You must be signed in to change notification settings - Fork 2
站点域名变更数据库替换操作
Xiaoshi Xu edited this page Aug 24, 2018
·
2 revisions
UPDATE `table` SET `field1`=REPLACE(`field1`, 'beforestring', 'afterstring');
###注意:此方案需要暂时闭站。
- 已 www.stmcu.org 更改为 www.stmcu.org.cn 为例。
- ssh进81,导出stmcu数据库
mysqldump -uroot -p -S /tmp/mysql-3316.sock pi_st_eefocus > st.sql
- 用sed命令将数据库文件中的www.stmcu.org 替换为 www.stmcu.org.cn
sed -e 's/www.stmcu.org/www.stmcu.org.cn/g' st.sql > st-new.sql
- 进入社区数据库,新建一个数据库pi_st_eefocus_new。
create database pi_st_eefocus_new;
- 将替换过的数据库文件导入新数据库
mysql -uroot -p -S /tmp/mysql-3316.sock pi_st_eefocus_new < st-new.sql
- 注意这里其实可以将旧数据库删除然后新建同样名称数据库,但是这个就需要临时给站点503. 附上503配置。
server {
listen 80;
server_name *.stmcu.org *.stmcu.org.cn;
error_page 503 /50x.html;
location = /50x.html {
root /usr/local/nginx/html;
}
location / {
return 503;
}
}