{"id":41748,"date":"2025-09-09T22:41:42","date_gmt":"2025-09-09T19:41:42","guid":{"rendered":"https:\/\/coma.lv\/2025\/09\/09\/how-to-find-and-replace-text-in-your-wordpress-database-in-one-click\/"},"modified":"2025-09-09T22:41:42","modified_gmt":"2025-09-09T19:41:42","slug":"how-to-find-and-replace-text-in-your-wordpress-database-in-one-click","status":"publish","type":"post","link":"https:\/\/coma.lv\/en\/2025\/09\/09\/how-to-find-and-replace-text-in-your-wordpress-database-in-one-click\/","title":{"rendered":"How to Find and Replace Text in Your WordPress Database in One Click"},"content":{"rendered":"\n<p style=\"text-align: left;\">If you want to find and replace a certain text, address or image, you can easily do it using a WordPress search and replace plugin or a simple SQL query.<\/p>\n<h2 style=\"text-align: left;\">When You May Need Search and Replace in the WordPress Database<\/h2>\n<p style=\"text-align: left;\">Say you have added a certain text or address to a number of your posts. You do not know which posts exactly you added it to, but you know there are very many of them. You can check the posts manually one by one, spend a lot of time on it and most likely miss something. With a search and replace command you can do the same thing much faster and more efficiently. The only thing to keep in mind is that if you make a mistake, you will not be able to undo it. Once the text is replaced, it is gone forever. So type carefully the text you are searching for and the text you will replace it with.<\/p>\n<h2 style=\"text-align: left;\">Getting Started<\/h2>\n<p style=\"text-align: left;\">As we mentioned above, the changes cannot be undone, so we advise you to back up your database \u2014 this can be done with a plugin or <a href=\"https:\/\/coma.lv\/en\/2025\/07\/16\/managing-a-wordpress-database-with-phpmyadmin-a-beginners-guide\/\" target=\"_blank\" rel=\"noopener\">phpMyAdmin<\/a> &#8211; after that you can start searching and replacing.<\/p>\n<h2 style=\"text-align: left;\">Search and Replace with a Plugin<\/h2>\n<p style=\"text-align: left;\">If you are not friends with code and do not want to write an SQL query, there is a simpler way to find and replace text. It is a WordPress plugin called Better Search Replace.<\/p>\n<p style=\"text-align: left;\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-36292 size-full\" src=\"https:\/\/coma.lv\/wp-content\/uploads\/2025\/09\/Ekranuznemums-2025-09-28-144426.jpg\" alt=\"WordPress\" width=\"1155\" height=\"642\" title=\"\" srcset=\"https:\/\/coma.lv\/wp-content\/uploads\/2025\/09\/Ekranuznemums-2025-09-28-144426.jpg 1155w, https:\/\/coma.lv\/wp-content\/uploads\/2025\/09\/Ekranuznemums-2025-09-28-144426-300x167.jpg 300w, https:\/\/coma.lv\/wp-content\/uploads\/2025\/09\/Ekranuznemums-2025-09-28-144426-1030x573.jpg 1030w, https:\/\/coma.lv\/wp-content\/uploads\/2025\/09\/Ekranuznemums-2025-09-28-144426-768x427.jpg 768w, https:\/\/coma.lv\/wp-content\/uploads\/2025\/09\/Ekranuznemums-2025-09-28-144426-705x392.jpg 705w\" sizes=\"auto, (max-width: 1155px) 100vw, 1155px\" \/><\/p>\n<p style=\"text-align: left;\">It lets you run search and replace commands right in the WordPress admin area.<\/p>\n<p style=\"text-align: left;\">The main advantage of Better Search Replace is that it works correctly with <strong data-start=\"1949\" data-end=\"1977\">serialized data<\/strong>, which is often stored in WordPress options and meta fields. This is especially important if you are replacing domain names or links with HTTPS \u2014 a simple text replacement can damage serialized arrays, so it is recommended to use a plugin or WP-CLI (see below).<\/p>\n<h2 style=\"text-align: left;\">Running a Search and Replace SQL Query in phpMyAdmin<\/h2>\n<p style=\"text-align: left;\">You can use <a href=\"https:\/\/coma.lv\/en\/2025\/07\/16\/managing-a-wordpress-database-with-phpmyadmin-a-beginners-guide\/\" target=\"_blank\" rel=\"noopener\">phpMyAdmin<\/a> to find and replace text in the WordPress database. First you need to log in to the cPanel admin of your hosting. Scroll down to the databases section and click phpMyAdmin.<\/p>\n<p style=\"text-align: left;\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-36295 size-full\" src=\"https:\/\/coma.lv\/wp-content\/uploads\/2025\/09\/Ekranuznemums-2025-09-28-120810.jpg\" alt=\"WordPress\" width=\"1168\" height=\"276\" title=\"\" srcset=\"https:\/\/coma.lv\/wp-content\/uploads\/2025\/09\/Ekranuznemums-2025-09-28-120810.jpg 1168w, https:\/\/coma.lv\/wp-content\/uploads\/2025\/09\/Ekranuznemums-2025-09-28-120810-300x71.jpg 300w, https:\/\/coma.lv\/wp-content\/uploads\/2025\/09\/Ekranuznemums-2025-09-28-120810-1030x243.jpg 1030w, https:\/\/coma.lv\/wp-content\/uploads\/2025\/09\/Ekranuznemums-2025-09-28-120810-768x181.jpg 768w, https:\/\/coma.lv\/wp-content\/uploads\/2025\/09\/Ekranuznemums-2025-09-28-120810-705x167.jpg 705w\" sizes=\"auto, (max-width: 1168px) 100vw, 1168px\" \/><\/p>\n<p style=\"text-align: left;\">The screenshot above shows the cPanel admin at Hostnet. Your admin may look different. phpMyAdmin will launch, where you need to click the name of the WordPress database and then click SQL.<\/p>\n<p style=\"text-align: left;\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-36298 size-full\" src=\"https:\/\/coma.lv\/wp-content\/uploads\/2025\/09\/Ekranuznemums-2025-09-28-121136.jpg\" alt=\"WordPress\" width=\"673\" height=\"209\" title=\"\" srcset=\"https:\/\/coma.lv\/wp-content\/uploads\/2025\/09\/Ekranuznemums-2025-09-28-121136.jpg 673w, https:\/\/coma.lv\/wp-content\/uploads\/2025\/09\/Ekranuznemums-2025-09-28-121136-300x93.jpg 300w\" sizes=\"auto, (max-width: 673px) 100vw, 673px\" \/><\/p>\n<p style=\"text-align: left;\">You will need to enter your SQL query as follows:<\/p>\n<pre class=\"brush: sql; title: ; notranslate\" title=\"\">\r\nupdate TABLE_NAME set FIELD_NAME =\r\nreplace(FIELD_NAME, &amp;#039;Text to find&amp;#039;, &amp;#039;text to replace with&amp;#039;);\r\n<\/pre>\n<p style=\"text-align: left;\">For example, if you wanted to find text in WordPress posts, you would write the query like this:<\/p>\n<pre class=\"brush: sql; title: ; notranslate\" title=\"\">\r\nupdate wp_posts set post_content =\r\nreplace(post_content, &amp;#039;Text to find&amp;#039;, &amp;#039;text to replace with&amp;#039;);\r\n<\/pre>\n<p style=\"text-align: left;\">Click the Go button to continue. phpMyAdmin will run the SQL query and, if successful, show the number of replaced rows. You can now go to your site to see the changes.<\/p>\n<p style=\"text-align: left;\">*Note: the table prefix may differ from the default <code data-start=\"3350\" data-end=\"3355\">wp_<\/code>.<\/p>\n<h2 style=\"text-align: left;\">An Alternative for Advanced Users: WP-CLI<\/h2>\n<p style=\"text-align: left;\" data-start=\"3516\" data-end=\"3758\">Today, for large sites and developers, one of the fastest ways to replace text is <a href=\"https:\/\/coma.lv\/en\/2025\/09\/30\/how-to-use-wp-cli-to-manage-wordpress\/\" target=\"_blank\" rel=\"noopener\">WP-CLI<\/a> \u2014 a command-line tool for managing WordPress. It also supports serialized data and can work with all tables at once.<\/p>\n<p style=\"text-align: left;\" data-start=\"3760\" data-end=\"3775\">Example command:<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\nwp search-replace &amp;#039;http:\/\/oldsite.com&amp;#039; &amp;#039;https:\/\/newsite.com&amp;#039; --all-tables\r\n<\/pre>\n<p style=\"text-align: left;\">This command will perform a safe replacement across the whole database and automatically handle serialization.<\/p>\n<hr \/>\n<p style=\"text-align: left;\"><em>Our specialization is WordPress website development and maintenance. Contact us for a free consultation \u2014 <a href=\"mailto:vadim@coma.lv\">vadim@coma.lv<\/a>, <a href=\"tel:+37129394520\">+371 29394520<\/a><\/em><\/p>\n<hr \/>\n","protected":false},"excerpt":{"rendered":"<p>If you want to find and replace a certain text, address or image, you can easily do it using a WordPress search and replace plugin or a simple SQL query. When You May Need Search and Replace in the WordPress Database Say you have added a certain text or address to a number of your [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":37650,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1225,1407],"tags":[],"class_list":["post-41748","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-wordpress","category-tutorials"],"_links":{"self":[{"href":"https:\/\/coma.lv\/en\/wp-json\/wp\/v2\/posts\/41748","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/coma.lv\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/coma.lv\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/coma.lv\/en\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/coma.lv\/en\/wp-json\/wp\/v2\/comments?post=41748"}],"version-history":[{"count":0,"href":"https:\/\/coma.lv\/en\/wp-json\/wp\/v2\/posts\/41748\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/coma.lv\/en\/wp-json\/wp\/v2\/media\/37650"}],"wp:attachment":[{"href":"https:\/\/coma.lv\/en\/wp-json\/wp\/v2\/media?parent=41748"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/coma.lv\/en\/wp-json\/wp\/v2\/categories?post=41748"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/coma.lv\/en\/wp-json\/wp\/v2\/tags?post=41748"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}