I’m exporting a WordPress site from localhost to a web host, and I am unable to import the Media Library, as the web host is unable to contact localhost.
I’ve uploaded all of the localhost files from /wp-content/uploads/…, and I’m thinking I just need to isolate the part of the MySQL database which contains the Media Library, and adjust the URL, then import the SQL into the web host database.
Can you tell me where the Media Library lives in the MySQL database please?
Will return all the entries in the Media Library.
After the execution, you can export the result table as SQL, or CSV, or any other portable data format you like. Remember, if you are not sure if the entries already exist in your database, use the
INSERT IGNORE
statement instead ofINSERT
. (This is possible through exporting pan in phpMyAdmin or other MySQL clients).Also, there are entries referring to the Media Library in each post, such as attachment images or thumbnail images, which are stored in the
wp_postmeta
table. WordPress stores them so the media “attaches” to posts or pages. If you want those to be exported too, you will need to use something like this :And then you can export them to wherever you want. It is all I know about media library stuff in WordPress.
The Media Library lives in both wp_posts and wp_postmeta.
Exporting and importing these 2 tables as SQL did not work for me – I received ‘duplicate entry for key 7’…
Exporting and importing these 2 tables as CSV did work, using “CSV using load data”.
Before importing, I emptied the 2 tables in the recipient database.
And then use PHP unserialize ‘meta_value’