I am trying to save a value in a cg_option row/field using phpmyadmin, however data is not stored correctly and when loaded again after saving, only part of data appears. Do I need to use a conversion function within phpmyadmin?

The row is theme_mods_[theme-name]

This is a sample of data contained in the field:

s:19:"thim_my_text_option" s:0:"" s:30:"thim_display_login_menu_mobile" b:0 s:25:"thim_body_secondary_color" s:7:"#4caf50" s:24:"thim_remove_query_string" b:0 s:21:"thim_google_analytics"

  • 2
    I guess that the theme does store its options as a serialized PHP data structure. You'll have a bad time updating those with mysql, as it does contain the length of arrays, strings etc.
    – janh
    Commented Nov 21, 2017 at 13:55
  • Do you have correct settings to your DB for example ENGINE = INNODB CHARACTER SET utf8 COLLATE utf8_general_ci Commented Nov 21, 2017 at 13:55
  • Yes. I suspect that this field requires some kind of encdoing/conversion. For instance passwords are stores selecting the MD5 encding option.
    – Riccardo
    Commented Nov 21, 2017 at 15:15
  • Added a data sample
    – Riccardo
    Commented Nov 21, 2017 at 15:26

5 Answers 5


The data is serialized.

In order to edit it, you need to unserialize it, edit, then serialize again, and save.

You can do that with PHP.

Check serialize and unserialize.

You can check this tool as well: serializededitor.com

  • how copying data from phomyadmin and pasting it in your tool will show an error invalid serialised data. Is data from phomyadmin already unserilaised?
    – Riccardo
    Commented Nov 26, 2017 at 14:57
  • Is not my tool =) Serialized data in phpMyAdmin is still serialized. I have no idea how your are pasting it and what it is, so I have no clue to help you. Try to open a new question and paste the raw data. Or if you don't want to open a new question, edit your question here. Or just use it paste.bin and paste the link here in the coments Commented Nov 26, 2017 at 15:00
  • Basically what I did was editing the row containing the serialised field, copying the text and pasting it in the serialising tool
    – Riccardo
    Commented Nov 26, 2017 at 15:04
  • serialziededitor.com did not work for me. I pasted the original Working string, and the webpage said there was an error -the page broke. Not sure how its usage differs from other tools. Fortunately, I found another one that worked. I am curious why it broke though, if you have any ideas. Commented Nov 27, 2018 at 23:48

Depending on your setup, there may be caching in place that would not be accounted for when accessing the database directly.

Is it possible for you to run set_theme_mod with the new value instead - via your functions.php file for example?

  • phpmyadmin would be faster if only could store properly the values...
    – Riccardo
    Commented Nov 21, 2017 at 13:52
  • 1
    It's not faster if it doesn't work :)
    – Welcher
    Commented Nov 21, 2017 at 13:53
  • @Riccardo literally an MU plugin in the mu-plugins folder, <?php set_theme_mod(...); is all you need
    – Tom J Nowell
    Commented Nov 21, 2017 at 14:23
  • or if you have WP CLI, wp shell will let you run the command directly too
    – Tom J Nowell
    Commented Nov 21, 2017 at 14:24
  • Basically you are telling me that you cannot use phpmyadmin to store values, apart from simple cases such as a user's password
    – Riccardo
    Commented Nov 21, 2017 at 15:14

I was able to paste a "broken" serialized database entry into this online tool:

  1. Paste a broken serialization string into the box.
  2. Click "Fix". It counts characters for you, outputting the fixed version in the box below.
  3. Copy-paste the corrected version into database table to fix.

In my case I had directly edited serialized text, which broke the character count, and for whatever reason, I had trouble getting the count right by hand.
The online tool properly counted characters and updated the serialization string for me.

Another useful online tool I found shows the PHP unserialized version of the string, which is nice.
But what I found useful for testing, is that it shows an error message above the above the unserialized output, if the character counts are wrong.
If no message shows, then your serialized string is (likely) correct.


I tried with serialize/unserialize but no way... So I finaly search thru the wordpress theme options to find where was the data I need to modify. Changing it inside the WordPress backend is the only way I have find to solve the problem. Not nice, but it works!


This is a nice tool that lets you do serialized string search and replace within your database: https://interconnectit.com/search-and-replace-for-wordpress-databases/

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.