Moving WordPress database and files to new host
Make input validation more user-friendly

You ask to enter host, user and port, and if one of them is empty you exit.
If I entered a host and a user and accidentally pressed enter for port (empty), I would be very unhappy with the script.

It would be better to put the prompting logic in a loop,
and repeat forever until a non-empty value is entered.
Ideally in a function, to reduce code duplication.

Exit with non-zero code on error

When exiting with error,
it's recommended to use a non-zero exit code.

~ is the same as $HOME

I prefer writing ~ because it's shorter.

Use printf instead of echo -e

The flags of echo are not portable.
To get the behavior of echo -e,
I suggest to make it a habit to use printf instead.

Replace awk + grep with just awk

In this command you use a combination of awk and grep:


eval $(awk -F "[()']" '/^define\(/{printf "%s='\''%s'\''\n", $3, $5;}' &lt; wp-config.php | grep DB_*)



You can do what grep does here in awk,
which will be more efficient.
The difference will be negligible in this example,
but it's good to make it a habit to avoid additional processes when easily possible.

Replace multiple sed calls when one is enough

This code rewrites the same file 3 times:


sed -i -e "s;\(define([[:space:]]*'DB_USER',[[:space:]]*\)\(.*\)\()\;\);\1'$local_db_user'\3;g"

  
  wp-config.php
      sed -i -e "s;(define([[:space:]]'DB_PASSWORD',[[:space:]])(.)()\;);\1'$local_db_password'\3;g" wp-config.php
      sed -i -e "s;(define([[:space:]]'DB_NAME',[[:space:]])(.)()\;);\1'$local_db_name'\3;g"
  wp-config.php


One sed would be enough, using multiple -e parameters.

Pointless cleaning up

Resetting the variables at the end of the script seem pointless.
This is only useful if you source this script, which seems unlikely.
If you run this script (as opposed to sourcing it),
then the variables you defined or modified will not be visible after the script has completed.