I have WP website with over 40,000 posts. Now I'll like to delete all posts, categories and tags. So All content and related meta. All I want to keep is static files. Is there a easy way to do this through database? Some query to drop all relevant tables? Sorry, I am not good with db and code, so please give me detailed explanation or full query. Thanks a lot. Plugins or any other solution, don't work for me, I need mysql query.
You wrote that you are not good with database, so please be extremely careful with the advice I present here.
First, learn how to backup your wordpress database and restore it from the backup file. This is critical to save you from catastrophe.
Second, there may be a plugin that will help you. I haven't looked but a friend was and said he found a "data migration" tool for wordpress.
Next, you can delete data from selected tables. Do not "drop" tables as that will eliminate the data structure in addition to the data. The result will be a broken wordpress. However, there are dependencies you must understand before using the SQL delete command.
A better approach would be learn to use a "selective" restore, loading only the tables that have the data you want to keep, e.g. wp-users. The idea here is to use the backup files to create a "baseline" database setup that suits your purpose.
If you find a data migration tool, you follow this procedure:
Keep in mind the data integrity. It is extremely important.
I hope something in this helps you.
While not instant, if you just need it once it might be more robust just do it through interface.
You can use screen options (top right corner of admin) to increase amount of items per page (I think it handles up to 999, but you might need to set less for it to work properly) and delete them via bulk actions page by page.
I hate posting a link-only answer, but the WordPress Suicide plugin is ideal for deleting almost all the data from a WordPress blog without needing any SQL knowledge.