inside in mysql_如何更改MySQL中字段內的URL?

There is a few places to work that out.

有幾個地方可以解決這個問題。

Backup your database

備份數據庫

Try using WordPress internal utility

嘗試使用WordPress內部實用程序

Search for matches

搜索匹配

Write your own search and replace

編寫自己的搜索和替換

Procedure

1. Backup your database

I generally go like so:

我一般都這樣:

mysqldump -u dbuser -p'dbpassword' --complete-insert --default-character-set=utf8 databasename > /home/renoirb/backups/databasename.sql

I even have this in a crontab on my own server. But that's an other topic.

我甚至在我自己的服務器上的crontab中有這個。但這是另一個話題。

2. Try using WordPress internal utility

WordPress has it's own utility for that matter. Most of the time, it can be done only with it.

WordPress擁有它自己的實用程序。大多數情況下,它只能用它來完成。

Simply add to your theme's functions.php (see wordpress documentation) file the following line:

只需添加到您的主題的functions.php(請參閱wordpress文檔)文件,如下所示:

update_option('siteurl','http://local.workspace/');

update_option('home','http://local.workspace/');

Assuming you are already running the theme that has that particular functions.php file.

假設您已經在運行具有該特定functions.php文件的主題。

Run the site, by refreshing the page.

通過刷新頁面來運行該站點。

Then, comment the lines!

然后,評論線!

You won't need them anymore.

你不再需要它們了。

Otherwise they get to update your database configuration at every page load.

否則,他們會在每次加載頁面時更新數據庫配置。

If it is not enough, continue...

如果還不夠,繼續......

3. Search for matches

I personally use Adminer on my deployment, it is a lightweight one-file replacement for PHPMyAdmin.

我個人在部署時使用Adminer,它是PHPMyAdmin的輕量級單文件替代品。

Why I suggest Adminer? It has a nice search all database feature that I find quite handy in our use-case.

為什么我建議Adminer?它有一個很好的搜索所有數據庫功能,我覺得在我們的用例非常方便。

It is a search box, labelled: "Search in data tables".

它是一個搜索框,標記為“在數據表中搜索”。

4. Write your own search and replace

UPDATE `wp_comments` SET `comment_author_url` = REPLACE(`comment_author_url`, "http://url", "https://url");

UPDATE `wp_postmeta` SET `meta_value` = REPLACE(`meta_value`, "http://url", "https://url");

UPDATE `wp_options` SET `option_value` = REPLACE(`option_value`, "http://url", "https://url");

Note that in my case, I was migrating ALL my urls from NON HTTPS to HTTPS.

請注意,就我而言,我將所有網址從非HTTPS遷移到HTTPS。

Hope that was helpful

希望這很有幫助

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值