Skip to content

站点域名变更数据库替换操作

Xiaoshi Xu edited this page Aug 24, 2018 · 2 revisions

方案1:Replace

UPDATE `table` SET `field1`=REPLACE(`field1`, 'beforestring', 'afterstring');

方案2:

###注意:此方案需要暂时闭站。

mysqldump -uroot -p -S /tmp/mysql-3316.sock pi_st_eefocus > st.sql
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;
    }
}
Clone this wiki locally