媒体库在数据库中的何处?
2 个回答
- 投票数
-
- 2012-10-11
媒体库同时存在于 wp_posts 和 wp_postmeta 中.
- wp_postmeta 包含图像URL
- wp_posts 包含每个插入到帖子中的图像的条目以及帖子ID.
由于SQL无法导出和导入这两个表-我收到了"键7的重复条目" ...
使用"使用加载数据的CSV"将这2个表作为CSV did 导出和导入.
在导入之前,我清空了收件人数据库中的2个表.
The Media Library lives in both wp_posts and wp_postmeta.
- wp_postmeta contains the image URL
- wp_posts contains an entry for each image insertion into a post, along with the post ID.
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.
-
从本地开发人员迁移到实时远程主机的另一种方法是使用[WP Migrate DB](https://wordpress.org/plugins/wp-migrate-db/).An alternative way to move from local developer to live remote host is to use [WP Migrate DB](https://wordpress.org/plugins/wp-migrate-db/).
- 0
- 2017-02-03
- Steve
-
- 2013-04-13
Select * from wp_posts where post_type = 'attachment';
将返回媒体库中的所有条目.
执行后,您可以将结果表导出为SQL或CSV或您喜欢的任何其他可移植数据格式.请记住,如果不确定数据库中是否已存在这些条目,请使用INSERT IGNORE
语句而不是INSERT
. (这可以通过在phpMyAdmin或其他MySQL客户端中导出pan来实现.)
另外,每个帖子中都有引用媒体库的条目,例如附件图像或缩略图图像,这些条目存储在wp_postmeta
表中. WordPress将它们存储起来,以便媒体"附加"到目录中.到帖子或页面.如果您也希望将其导出,则将需要使用以下内容:SELECT * FROM `wp_postmeta` WHERE meta_key IN ( '_wp_attached_file', '_wp_attachment_backup_sizes', '_wp_attachment_metadata', '_thumbnail_id' )
然后您可以将它们导出到所需的任何位置.这就是我对Wordpress中媒体库内容的了解.
Select * from wp_posts where post_type = 'attachment';
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 theINSERT 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 thewp_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 :SELECT * FROM `wp_postmeta` WHERE meta_key IN ( '_wp_attached_file', '_wp_attachment_backup_sizes', '_wp_attachment_metadata', '_thumbnail_id' )
And then you can export them to wherever you want. It is all I know about media library stuff in Wordpress.
-
您在WordPress开发的黑暗世界中为我提供了一小部分光You've provided me a small bit of light in the world of darkness that is WordPress development
- 8
- 2017-10-12
- kbuilds
-
什么是"出口锅"?What is "exporting pan" ?
- 0
- 2020-07-21
- SherylHohman
我正在将WordPress网站从localhost导出到Web主机,并且由于Web主机无法联系localhost,所以无法导入媒体库.
我已经从/wp-content/uploads/...上传了所有的localhost文件,我想我只需要隔离MySQL数据库中包含媒体库的部分,并调整URL,然后将SQL导入到Web主机数据库中.
您能告诉我媒体库在MySQL数据库中的位置吗?