3

I wonder if there are any conventions or best practices about the table prefix of any WordPress set up. The official documentation on wordpress.org does not make any statements to that topic.

Furthermore, should I concider the prefix to be a security factor in a case that it obfuscate the table names for a potential invader?

1 Answer 1

4

First of all, the prefix is only a configuration option and not a security feature. The reason is that once an attacker has access to your database, he can find out any exisiting table prefix within seconds. There's no way this obscurity protects you from any attack.

For the prefix itself, WordPress asks you to use only digits, letters (here only basic Latin letters a-z are meant) and underscores. (This can be found inside a PHP comment in the wp-config-sample.php file right above the prefix declaration. In theory, with MySQL you can use almost every character in a object name as long as you quote the object name in any situation:

SELECT `über_col` from `über_table` …

Would be possible, however. For compatibility reasons (means: compatibility with queries that don't quote their object names in backticks) you should follow the suggestion inside wp-config-sample.php which follows basically the MySQL specification for unquoted object names.

Furthermore the specification points out, that a table name must not be longer than 64 characters. So basically its a good idea to keep the prefix short.

To be even compatible with SQLite, you should avoid a digit as first character of the prefix.

Conclusion

A table prefix:

  • should only contain Latin letters (a-z), digits (0-9) and underscores (_).
  • should not start with a digit (0-9)
  • should not consists solely of digits
  • should be as short as possible
3
  • This will be really useful info in the codex aswell, I think you have just scored yourself some work adding this in the codex ;-) Commented Aug 28, 2015 at 8:40
  • You're talking about codex.wordpress.org? Didn't participated yet. I think it's time to find out, how.
    – David
    Commented Aug 28, 2015 at 8:53
  • All you need is to register on wordpress.org if you haven't yet done it. Once you log in, you can edit etc any page in the codex ;-) Commented Aug 28, 2015 at 9:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.