$> mysqldump -d my_database > my_database_structure.sql #the -d is to not include the data simply the table structure of the database. $> perl db_relation.pl my_database_structure.sql > my_database_relations.txt #the script will print to STDOUT unless directed to a textfile.