if you have shell access, life is easy:
use mysqldump to download database A
(you'll probably want to use --opt options -- see mysqldump --help)
Then logging into the B server, log into mysql, use the B database and use the source command to load the dump into db B.
See mysql --help
You can also write php exec commands to do the above.