How to update media links in WordPress after migration?

As mentioned in the comments under your question, some data in the WordPress database is serialized and therefore not possible to change with a simple find and replace.

You should read through the Moving WordPress section of the codex. Specifically the Changing Your Domain Name and URLs portion. I usually use a plugin or a command line tool depending on what’s available to me.

Plugin:

Better Search Replace is a useful plugin recommended in the entry above. There are other plugins that will do the same things but this is my preference. Some features that I enjoy are:

  • Support for serialized data.
  • The ability to select single or multiple tables.
  • A “dry run” feature to test and verify your changes before actually performing them.
  • Very few server requirements (all you need is a WP instance.)

CLI Tool:

Another option that handles serialized data is the WP-CLI’s search-replace tool. This option is used from the command line via something like SSH and requires the wp-cli to be installed on the server. You can take a look at the docs for all available options and examples but the basic usage is:

# Search for old domain name and replace it with a new one
$ wp search-replace 'http://old.example.dev' 'http://new.example.com'