This is mainly a cheat sheet for me to remember. Nothing rocket science.
It often makes sense to use netcat/nc to copy MySQL database between hosts in trusted networks. It bypasses encryption overhead of SSH and depending on configuration can be significantly faster.
Also note MySQL should be down when you copy data unless you’re copying from snapshot etc.
So to copy go to the mysql data directory on both boxes; such as cd /var/lib/mysql . Make sure target directory is empty. Now on the TARGET server do nc -l 4000 | tar xvf – and on the SOURCE server do tar -cf – . | nc target_ip 4000
Also note – the port you’re using should be open in the firewall.