Discuz Method for Bulk Replacement of Post Content (Update Database with SQL)

  • 2021-07-02 23:43:38
  • OfStack

Today, a friend's Discuz X2 forum needs to replace the content of posts in batches, and the number of posts is tens of thousands. At the beginning, it was filtered by setting words, and it was found that it had no effect, so it could only be replaced in batches through the database. Please continue to look down on the specific methods.

The background of Discuz X2 forum provides the function of database SQL statement operation, but by default, this function is turned off for security reasons, so it is necessary to modify the configuration file first, as follows:

Locate the forum program file config/config_global. php, open it with Notepad, then look for $_ config ['security'] ['querysafe'] ['status'] and set it to 0, continue looking for $_ config ['admincp'] ['runquery'] and set it to 1. (For security reasons, it is recommended to change the values of these two parameters back after executing the SQL statement.)

The following teaches you how to modify the content of posts in batches by Discuz X2:

1. Enter the background of Discuz X2 → Webmaster → Database → Upgrade

2. Enter the following statement and submit it:


UPDATE pre_forum_post SET message=REPLACE(message,"" What to replace "","" New content "");


Related articles: