Question

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

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?


Submit an answer

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!

Sign In or Sign Up to Answer

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.

Want to learn more? Join the DigitalOcean Community!

Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in Q&A, subscribe to topics of interest, and get courses and tools that will help you grow as a developer and scale your project or business.

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