ProblemYou want to shove the output from another program into mysql. SolutionUse a pipe . DiscussionSection 1.12 used the following command to show how mysql can read SQL statements from a file: % mysql cookbook < limbs.sql mysql can also read a pipe, which means that it can receive output from other programs as its input. As a trivial example, the preceding command is equivalent to this one: % cat limbs.sql | mysql cookbook Before you tell me that I've qualified for this week's "useless use of cat award," [
C:\> type limbs.sql | mysql cookbook % mysqldump cookbook | mysql -h some.other.host.com cookbook Program-generated SQL also can be useful when you need to populate a table with test data but don't want to write the INSERT statements by hand. Instead, write a short program that generates the statements, and then send its output to mysql using a pipe: % generate-test-data | mysql cookbook See AlsoChapter 10 discusses mysqldump further. |