2016년 2월 18일 목요일

워드프레스] 기 등록된 Media 정보 file url 정보 변경 방법


워드프레스에 기 등록된 Media의 File URL 정보를 MySQL DB에서 변경



  1. MySQL DB에 접속한다.
  2. wp_posts 테이블에서 attachment_id와 일치하는 게시물의 정보를 조회후 변경하는 Query를 다음과 같이 실행한다.

mysql> select id, guid from newface_posts where id = 906;
+-----+--------------------------------------------------------------------+
| id  | guid                                                               |
+-----+--------------------------------------------------------------------+
| 906 | http://old_ip/wp-content/uploads/2015/06/치아미백024.jpg     |
+-----+--------------------------------------------------------------------+
1 row in set (0.00 sec)

mysql> update newface_posts set guid = replace(guid, 'http://old_ip', 'http://new_ip') where id = 906;
Query OK, 1 row affected (0.00 sec)
Rows matched: 1  Changed: 1  Warnings: 0

mysql> select id, guid from newface_posts where id = 906;                       +-----+-------------------------------------------------------------------+
| id  | guid                                                              |
+-----+-------------------------------------------------------------------+
| 906 | http://new_ip/wp-content/uploads/2015/06/치아미백024.jpg     |
+-----+-------------------------------------------------------------------+
1 row in set (0.00 sec)
mysql>

워드프레스에서 다시 게시물을 조회하면 변경되어 보여진다.
이 글은 Evernote에서 작성되었습니다. Evernote는 하나의 업무 공간입니다. Evernote를 다운로드하세요.