WordPress 글 속의 사이트 url을 찾아 일괄 변경하기

워드프레스

http://프로토콜로 등록되어 버린 URL을 https://로 변경하는 절차를 설명합니다.

mysql로그인

root로 로그인합니다.

$ sudo mysql -u root -p
Enter password:*********

존재하는 데이터베이스 리스트를 표시합니다.

MariaDB [(none)]> show databases;
+--------------------+
| Database           |
+--------------------+
| wp                 |
| information_schema |
| mysql              |
| performance_schema |
+--------------------+
4 rows in set (0.006 sec)

wp데이터베이스를 기본 사용으로 선택합니다.

MariaDB [(none)]> use wp;

글 내용에 포함된 URL 일괄 변경

MariaDB [wp]> select count(*) from wp_posts where  post_content like '%www.zinnunkebi.com%';
+----------+
| count(*) |
+----------+
|      238 |
+----------+
1 row in set (0.025 sec)
MariaDB [wp]> UPDATE wp_posts SET post_content = REPLACE(post_content , 'www.zinnunkebi.com', 'www2.zinnunkebi.com') WHERE post_content LIKE '%www.zinnunkebi.com%';
Query OK, 238 rows affected (0.431 sec)
Rows matched: 238  Changed: 238  Warnings: 0

카테고리 설명에 포함된 URL 일괄 변경

MariaDB [wp]> select count(*) from wp_term_taxonomy where description like '%https://www.zinnunkebi.com%';
+----------+
| count(*) |
+----------+
|       11 |
+----------+
1 row in set (0.001 sec)

MariaDB [wp]> UPDATE wp_term_taxonomy SET description = REPLACE(description , 'www.zinnunkebi.com', 'www2.zinnunkebi.com') WHERE description LIKE '%www.zinnunkebi.com%';
Query OK, 11 rows affected (0.008 sec)
Rows matched: 11  Changed: 11  Warnings: 0

테마에 포함된 URL 일괄 변경

특정 테이블에 저장된 내용중 http://tech.zinnunkebi.com/로 시작된 문자열을 찾아 표시합니다.

MariaDB [wp]> select icon from wp_cocoon_speech_balloons where icon like 'http://tech.zinnunkebi.com/%';
+----------------------------------------------------------------------------------+
| icon                                                                             |
+----------------------------------------------------------------------------------+
| http://tech.zinnunkebi.com/wp-content/themes/cocoon-master/images/b-man.png      |
| http://tech.zinnunkebi.com/wp-content/themes/cocoon-master/images/b-woman.png    |
| http://tech.zinnunkebi.com/wp-content/themes/cocoon-master/images/ojisan.png     |
| http://tech.zinnunkebi.com/wp-content/themes/cocoon-master/images/obasan.png     |
| http://tech.zinnunkebi.com/wp-content/themes/cocoon-master/images/doctor.png     |
| http://tech.zinnunkebi.com/wp-content/themes/cocoon-master/images/doctress.png   |
| http://tech.zinnunkebi.com/wp-content/themes/cocoon-master/images/doya-man.png   |
| http://tech.zinnunkebi.com/wp-content/themes/cocoon-master/images/doya-woman.png |
+----------------------------------------------------------------------------------+
8 rows in set (0.000 sec)

표시된 http://tech.zinnunkebi.com/로 시작된 문자열을 https://tech.zinnunkebi.com/로 변경합니다.

MariaDB [wp]> UPDATE wp_cocoon_speech_balloons SET icon = REPLACE(icon, 'http://tech.zinnunkebi.com/', 'https://tech.zinnunkebi.com/') WHERE icon LIKE 'http://tech.zinnunkebi.com/%';

변경된 결과를 확인합니다.

MariaDB [wp]> select icon from wp_cocoon_speech_balloons;
+-----------------------------------------------------------------------------------+
| icon                                                                              |
+-----------------------------------------------------------------------------------+
| https://tech.zinnunkebi.com/wp-content/themes/cocoon-master/images/man.png        |
| https://tech.zinnunkebi.com/wp-content/themes/cocoon-master/images/woman.png      |
| https://tech.zinnunkebi.com/wp-content/themes/cocoon-master/images/b-man.png      |
| https://tech.zinnunkebi.com/wp-content/themes/cocoon-master/images/b-woman.png    |
| https://tech.zinnunkebi.com/wp-content/themes/cocoon-master/images/ojisan.png     |
| https://tech.zinnunkebi.com/wp-content/themes/cocoon-master/images/obasan.png     |
| https://tech.zinnunkebi.com/wp-content/themes/cocoon-master/images/doctor.png     |
| https://tech.zinnunkebi.com/wp-content/themes/cocoon-master/images/doctress.png   |
| https://tech.zinnunkebi.com/wp-content/themes/cocoon-master/images/doya-man.png   |
| https://tech.zinnunkebi.com/wp-content/themes/cocoon-master/images/doya-woman.png |
+-----------------------------------------------------------------------------------+
10 rows in set (0.000 sec)

댓글

제목과 URL을 복사했습니다