终极精品

标题: discuz:远程附件与本地附件的之间的转换教程 [打印本页]

作者: zhoji    时间: 2020-5-1 23:30
标题: discuz:远程附件与本地附件的之间的转换教程
最近本人因为想把阿里云OSS的远程附件搬到自己本地服务器上。最后图片啥的都搬回来准备妥当了,然而帖子图片却打不开了,显示的还是远程地址,最后去网上搜了下原因,才知道还要执行数据库升级,下面是操作教程!


第一步,使用FTP把本地 /data/attachment/ 目录下的文件下载到本地,这里我只用到了文件目录下的/forum,/portal和/block

                               
登录/注册后可看大图

第二步,FTP登录远程服务器。分别把下载下来的三个文件夹里的上传到远程服务器对应的目录里。


                               
登录/注册后可看大图

第三步,数据库执行sql语句,



论坛的:(0表示本地,1表示远程)

  1. update pre_forum_attachment_1 set remote=1 where remote=0; update pre_forum_attachment_2 set remote=1 where remote=0; update pre_forum_attachment_3 set remote=1 where remote=0; update pre_forum_attachment_4 set remote=1 where remote=0; update pre_forum_attachment_5 set remote=1 where remote=0; update pre_forum_attachment_6 set remote=1 where remote=0; update pre_forum_attachment_7 set remote=1 where remote=0; update pre_forum_attachment_8 set remote=1 where remote=0; update pre_forum_attachment_9 set remote=1 where remote=0;
复制代码
门户的:

  1. update pre_portal_article_title set remote=1 where remote=0; update pre_portal_attachment set remote=1 where remote=0; update pre_portal_topic_pic set remote=1 where remote=0;
复制代码
进入论坛后台,依次点击:站长-数据库-升级



                               
登录/注册后可看大图

把数据库升级语句复制到箭头方向,点击升级。(最好备份一下数据库)

之后更新网站缓存,进入网站随便点开一个之前附件在本地的帖子。邮件附件复制链接,如果链接地址和后台设置的远程访问 URL一致,表示迁移成功,就可以把本地的对应目录下的文件删除了。

之后更新网站缓存,进入网站随便点开一个之前附件在本地的帖子。邮件附件复制链接,如果链接地址和后台设置的远程访问 URL一致,表示迁移成功,就可以把本地的对应目录下的文件删除了。





                               
登录/注册后可看大图

以上是本地附件转换成远程附件的方法!如果以后不用远程附件了!只要反着操作就行了,比如数据库执行sql语句

  1. update pre_forum_attachment_1 set remote=0 where remote=1; update pre_forum_attachment_2 set remote=0 where remote=1; update pre_forum_attachment_3 set remote=0 where remote=1; update pre_forum_attachment_4 set remote=0 where remote=1; update pre_forum_attachment_5 set remote=0 where remote=1; update pre_forum_attachment_6 set remote=0 where remote=1; update pre_forum_attachment_7 set remote=0 where remote=1; update pre_forum_attachment_8 set remote=0 where remote=1; update pre_forum_attachment_9 set remote=0 where remote=1;
复制代码
  1. update pre_portal_article_title set remote=0 where remote=1; update pre_portal_attachment set remote=0 where remote=1; update pre_portal_topic_pic set remote=0 where remote=1;
复制代码
把0和1对掉下就OK了!很简单吧,记得收藏备用哟.







欢迎光临 终极精品 (http://www.chnspy.com/) Powered by Discuz! X3.2