the best way is to use mysqldump and dump the file to text.
using a script to copy it record by record is a very bad idea.
Read the manuals about mysqldump and the mysql-commandline tool, because you can send the output of mysqldump directly to the commandline-tool on a different server, so you can dump the old database straight into the new database without making a dump-file.
PS 500MB is quite small. 50GB is big, 50TB is very big.