0

I am not able to find, How can I change the only options table prefix. I do not want to change other tables prefix only need to change options prefix.

Please guide me.

Thanks

  • And why do you want to do that? – Sumit May 20 '16 at 6:57
  • My client wants to change for security reasons. – Deepti chipdey May 20 '16 at 7:27
  • IMO it isn't the good thing and impossible to do. Because WordPress handle only one table prefix. And for security reasons you can change prefix for all tables. This make no sense for one table. – Sumit May 20 '16 at 7:31
3

This is actually not that hard, but you will have to excuse me for keeping it high level because this is just a stupid thing to do as all things which are security by obscurity.

All you need to do is write your WPDB driver, which inherits the WPDB class. Place it in /wp-content/db.php file and make sure to initialize the global $wpdb object with your class.

At the driver intercept every SQL that should go to the options table and replace the name of the table in the SQL with whatever you want.

It sounds like something scary to do but it actually isn't, and not a lot of work is involved.

Just for people that come here and don't understand what is wrong about the whole idea: Table names are globals which are assumed by core and plugins to follow specific pattern, changing it might break in the future when new tables or patterns are used, or even break now with things like backup plugins that assume some "magic" knowledge of the DB to minimize the need of explicit user configuration.

| improve this answer | |
0

WordPress uses a single table prefix for all tables and I always set a different prefix for each site I build to improve security. You could tell your client that security is even better if you do this for all tables.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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