Report this

What is the reason for this report?

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

Posted on May 31, 2020

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 and wp_postmeta tables, and the settings in the wp_options table.

So, I already the restored the posts using the wp_posts and wp_postmeta, 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 wp_options table in mysql without using phpmyadmin. How to export only tablepress_tables and tablepress_options contents from inside the wp_options table inside a “wordpress” database using command line on mysql 5.7? and then imported into the new database?



This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

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.

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.

https://dev.mysql.com/doc/refman/5.7/en/mysqldump.html

BR

Andrew

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Get started for free

Sign up and get $200 in credit for your first 60 days with DigitalOcean.*

*This promotional offer applies to new accounts only.