Part of Datorkirurgen AB – IT experts across Sweden

WordPress database security covers everything from the database user and its permissions to the table prefix, wp-config.php and the security keys. Business IT Support reviews and hardens the database, and we also find malicious code that attackers hide there.

Malicious code also lives in the database

Many people believe that a clean set of files means a clean website. However, attackers often store malicious code, spam links and fake administrators in the database instead. For example, a script can sit inside a widget, an option or a post and load again every time a page opens.

Therefore, a real clean-up always includes the database. We search options, posts, metadata and users for suspicious content, and we compare the results with a known clean state where one exists.

Database query showing unauthorised administrators as part of WordPress database security
Database query showing unauthorised administrators. Accounts like these often survive a clean-up that only covers the files.

WordPress database security: users and permissions

First of all, WordPress should connect with its own database user, never with the root account. That user only needs rights to its own database. As a result, a compromised site cannot read or damage other databases on the same server.

In addition, we review the WordPress users stored in the database. Administrator accounts should be few, personal and protected with strong passwords and two-factor authentication. Consequently, a stolen password from a former employee cannot open the site.

Database query with hacked posts during a WordPress database security review
Database query showing posts that an attacker published. We review content and users directly in the database.

Posts, options and metadata

In particular, attackers like the options table, because WordPress loads many options on every request. Moreover, they hide code in post metadata and in serialised data that is hard to read. We therefore search for typical patterns such as base64 strings, eval calls, iframes and unknown script sources.

Whenever we find something, we then trace where it comes from. For instance, a malicious option may belong to a fake plugin. In that case, we remove both the plugin and its data, so the code does not return.

Finally, we take a fresh backup of the clean database and store it outside the server. As a result, you always have a known good copy to return to, and we can compare future changes against it. In addition, we schedule regular database backups with a retention period that matches your needs.

wp-config, security keys and table prefix

Similarly, the file wp-config.php holds the database password and the security keys. For that reason, it needs strict file permissions and should sit outside the public web folder when possible. We also replace the security keys after every suspected intrusion, which signs out all logged-in users.

A custom table prefix instead of the default wp_ gives a small extra barrier against automated attacks. However, it is not a security measure on its own. Therefore, we combine it with updates, a firewall, backups and monitoring.

Settings in wp-config with the table prefix for WordPress database security
Settings in wp-config.php with the table prefix. The file holds the database credentials and needs strict permissions.
WordPress user list with unknown administrators
The WordPress user list with unknown administrators. We compare the users in the dashboard with the database.
Unknown administrator account in WordPress
An unknown administrator in WordPress. We remove accounts like this and close the way in.

Contact Datorkirurgen AB about WordPress database security

Business IT Support is part of Datorkirurgen AB, which has more than 30 years of experience in IT for businesses. We review, clean and harden WordPress databases for companies remotely anywhere, and on site in Stockholm and across Sweden.

In addition, our prices start at €250 per hour excluding VAT, or as agreed, and we guarantee to solve the problem. WordPress gives advice in its WordPress hardening guide. Contact us, and we will start with a review of your database.

Frequently asked questions about WordPress database security

WordPress database security basics

Clean-up and investigation

Prevention and support

Website developed by Datorkirurgen AB · Privacy policy