banner
rabithua

rabithua

twitter
github

MySQL Curveball

The specific issue is that the other day I couldn't stand the speed of my navigation site anymore, so I decided to replace all the images with cos images. I can't manually change so much content one by one...

Since I knew that MySQL has SQL statements that can easily perform some operations, but I am a novice, so I asked my brother, a half-hearted programmer who knows some data operations, but after asking around, I gave up.

Mainly, what I want to replace is a part of the field content. For example, the original image link is https://daohang.wowow.club/image/A.png, and I want to replace the domain part with the cos domain, leaving the rest unchanged.

But he only knew the SQL statement for replacing all, not for partial replacement. Am I supposed to replace them one by one? Later, after searching online, I found a workaround - SQL export, open it locally with a text editor for replacement, you know how to replace in Word, right?

I used Hbuilder to open and replace, and then imported it into the database.

The main point is to share this idea, with this idea, even novices can deal with daunting databases~

Practical Process#

Access the database, find out which table contains the content you need to replace

image

Export this table, open it for replacement locally using Hbuilder

image

Then delete the original table in the database (typecho_fields), import it into the database (daohang), pay attention to these two steps, if you don't delete the original table, importing directly will result in an error.

Loading...
Ownership of this post data is guaranteed by blockchain and smart contracts to the creator alone.