简体   繁体   中英

Mysql replace file extension stored in database

Am working with a wordpress site, that use to have a lot heavy of png files on the uploads folder, (wp-content/uploads/year/month/filenames.png)

To reduce the disk usage on server I changed all the files to be .jpg, but, there are still a lot of references in the database (on the wp-post table in the guid column) pointing to the old .png files.

I would like to know if there is a way in mysql to find and replace all the text ".png" for ".jpg" in the column guid, but, only for those records that contains "wp-content/uploads/" (that would mean that am changing only the references to the files I changed and no others like maybe on wordpress themes)

Any solution is welcome, CLI commands, sql commands....

You could use an SQL query in adminer or phpmyadmin. But try Search RegEx , a good plugin to be able to search and replace (optionally with grep) through all posts, pages, excerpts, comments, titles and meta.

You can find and replace only in post/page content, do a trial run without replacing to see what is being replaced, and more. Your images are in post/page content, not in the GUID column.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM