Wordfence and Missing Tables

Wordfence is a great plugin for WordPress sites.  Great for managing, notifying, and all around blocking malicious activity.  It’s one of the more highly touted security plugins, and it earns its title.

However, after an update a while back, they added a Dashboard widget, which gives you an at-a-glance info tool for what Wordfence has done for you lately.  But, my error log, and the lack of data, showed there was a problem.  My version simply would not create the required tables, even when fully removed and reinstalled.

I took the error log from the reinstall, which stated that it could not create the table, and spit out the query it was trying to use (in this case, two tables).  I tried to execute the queries, but was met with errno: -1.

The trick was to create the tables with a different name, and then rename them to the proper version.  Here’s the two original queries used in the install:

Selec All Code:
CREATE TABLE IF NOT EXISTS wp_wfFileChanges (
 filenameHash CHAR(64) NOT NULL PRIMARY KEY,
 file VARCHAR(1000) NOT NULL,
 md5 CHAR(32) NOT NULL
 ) DEFAULT charset=utf8
Selec All Code:
CREATE TABLE IF NOT EXISTS wp_wfBlockedIPLog (
 IP INT UNSIGNED NOT NULL,
 countryCode VARCHAR(2) NOT NULL,
 blockCount INT UNSIGNED NOT NULL DEFAULT 0,
 unixday INT UNSIGNED NOT NULL,
 PRIMARY KEY(IP, unixday)
 ) DEFAULT charset=utf8

Rename the wp_wfFilesChanged to be something like wp_wfFilesChanged2 in the query, then after the table is made, rename it back to wp_wfFilesChanged.

If you don’t know how to do any of this, do not muck around in your SQL table without consulting someone who understands them.

Posted in Uncategorized.