Skip to main content

WordPress – How to perform Search and Replace on whole Database (post, pages, wp_options) using WP plugins or MySQL tools

Those who are frequently working with Worpress often find themselves operating mass-replace tasks throughout the whole WP Database. Such situation most likely arises in the following scenarios:

  • WebSite URL change (from  www.url-a.com to www.url-b.com), meaning we have to replace the old one in all of our posts/pages.
  • Invalid character issues (mostly due to charset)
  • Having to rename one or more keywords, tags, categories or more (for standard URL & links consistency).
  • Presence of a typo within multiple posts, which you would like to fix without performing thousands of edits.

When we need something like that, we can choose between two possible routes: going for a WordPress plugin to handle such issue in a managed way or work at database level with the help of some free and/or open MySQL management tools.

Read More

WordPress – How to retrieve all posts from one or more given categories with a SQL query

Today a client asked me to remove all the posts from a given category to the auto-generated XML Sitemap of his WordPress blog and also redirect these posts to a new website (same slug, different host): here’s a quick report of how I managed to do that, hoping that it would also help other System Administration that will be given these same tasks.

Read More

How to fix “MySQL server has gone away”, “Packets out of order” and similar MySQL connection errors

If you’re a fond MySQL and/or MariaDB user you most certainly experienced at least one of these common errors:

MySQL server has gone away

Error reading result set’s header

Error executing query

MySQL server has gone away for query

2006, MySQL server has gone away

Packets out of order. Expected X received Y. Packet size=Z

… and so on. You can find these warnings basically anywhere, as they are usually written in the log files of the applications, tools and services that try to connect to your database and fail: however, in most scenarios, they are firstly noticed by the zealous System Administrator inspecting the PHP error log file (or the Joomla or WordPress counterpart) while trying to understand why his beloved web site or service isn’t working like it should.

That said, let’s try to understand the underlying cause and see what we can do to overcome them.

Read More

How to fix MSXML2.XMLHTTP and MSXML2.ServerXMLHttp Error 0x80070057 – The Parameter is Incorrect when executing a POST HTTP connection within a T-SQL Stored Procedure

If you found this post it probably means that you are experiencing the following scenario:

  • A Windows 2012 or Windows 2016 Server machine with SQL Server 2008, SQL Server 2008R2, SQL Server 2012, SQL Server 2014, SQL Server 2016 and so on.
  • A Stored Procedure using a MSXML2 object that calls a Web Service (or any other external URL) with a POST request (see below).
  • An error 0x80070057 (or -2147024809) occurring as soon as you call the “SEND” method (see below), which translates (when inspected using sp_OAGetErrorInfo) as The parameter is incorrect.

Here’s an example of a SP that might throw such error:

Read More

How to get the size of all MySQL Tables in all Databases (and other size-related queries)

Yesterday I was trying to investigate through an odd size increment affecting one of our MySQL databases. Since I didn’t knew about the table(s) affected by the issue, the first thing I needed to do was to take a look at each table size among the various DB that were there.

I managed to perform such analysis in few minutes with these great queries, loosely based upon those present within this StackOverflow answer.

Read More

Close