![]() |
|
|
#1 |
|
Administrator
Join Date: Jun 2004
Posts: 383
|
3.5 Using mysql in Batch Mode
In the previous sections, you used mysql interactively to enter queries and view the results. You can also run mysql in batch mode. To do this, put the commands you want to run in a file, then tell mysql to read its input from the file:
shell> mysql < batch-fileIf you are running mysql under Windows and have some special characters in the file that cause problems, you can do this: dos> mysql -e "source batch-file"If you need to specify connection parameters on the command line, the command might look like this: shell> mysql -h host -u user -p < batch-fileEnter password: ********When you use mysql this way, you are creating a script file, then executing the script. If you want the script to continue even if some of the statements in it produce errors, you should use the --force command-line option. Why use a script? Here are a few reasons:
+---------+| species |+---------+| bird || cat || dog || hamster || snake |+---------+In batch mode, the output looks like this instead: speciesbirdcatdoghamstersnakeIf you want to get the interactive output format in batch mode, use mysql -t. To echo to the output the commands that are executed, use mysql -vvv. You can also use scripts from the mysql prompt by using the source or \. command: mysql> source filename;mysql> \. filename |
|
|
|
![]() |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | Search this Thread |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Import Access, Excel and data of other formats to MySQL by Navicat | NavicatGuy | Articles | 0 | 08-17-2004 01:08 AM |
| 3.2 Entering Queries | Administrator | Documentation | 0 | 06-09-2004 02:58 AM |
| 1.4.3.2 Using the MySQL Software for Free Under GPL | Administrator | Documentation | 0 | 06-08-2004 02:20 AM |
| 1.2.2 The Main Features of MySQL | Administrator | Documentation | 0 | 06-08-2004 01:55 AM |
| 1.2 Overview of the MySQL Database Management System | Administrator | Documentation | 0 | 06-07-2004 10:11 PM |