How to export/import some data from database table using mysql commands

Posted May 31, 2020 2k views

I’m trying to switch servers for a WordPress site, and I’m starting clean so, I’m only transferring the essential tables to the new db, and the I’m reconfiguring everything again manually.

The only issue is that I’m using the TablePress plugin which stores its data in the wp_posts andwp_postmeta tables, and the settings in the wp_options table.

So, I already the restored the posts using the wpposts and wppostmeta, the entries from TablePress plugins are already in the database, but the content doesn’t show up in TablePress, because the index and options are located in the wp_options table.

The plugin developers has said to export the tablepress_tables and tablepress_options entries from the wp_options table. However, I don’t know the syntax to export and import the entries from a tablet, in this case from the wpoptions table in mysql without using phpmyadmin.
How to export only `tablepress
tablesandtablepressoptionscontents from inside thewpoptions` table inside a “wordpress” database using command line on mysql 5.7? and then imported into the new database?

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Submit an Answer
1 answer

There’s a MySQL client tool called MySQLdump (installed by default with MySQL). It’s the original method for backing up MySQL data. It essentially connects to the mysqld server and writes out all the statements needed to recreate the data from scratch.

The mysqldump utility can filter the data being dumped out to a file using a WHERE argument so you can extract only that data that’s important to you in this scenario.

The command you would run on the server hosting the database would look something like;

mysqldump -u {username} -p --where="column = 'tablepresstables' or column = 'tablepressoptionscontents'" wordpress_db_name > destination_file.sql

You should review the utility documentation to tune the command to exactly what you need.