Home >> FAQs/Tutorials >> MySQL Tutorials

MySQL Tutorial - "mysql" Command Line Arguments

By: FYIcenter.com

(Continued from previous topic...)

What Are the "mysql" Command Line Arguments?

"mysql" supports only one optional command line argument, "database". But "mysql" allows the operating system to redirect input and output streams at the command line level. Here are some good examples:

  • "mysql databaseName" - Starts "mysql" in interactive mode and use the specified database.
  • "mysql < fileName" - Starts "mysql" in batch mode and executes all commands in the specified file.
  • "mysql < fileName > fileName" - Starts "mysql" in batch mode, executes all commands in the specified file, and write output to the specified file.

Here is a tutorial exercise of how to use the command line argument to specify the database to use:

>cd \mysql\bin
>mysql -u root test
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 4 to server version: 5.0.24

mysql> show tables;
+----------------+
| Tables_in_test |
+----------------+
| links          |
+----------------+
1 row in set (0.00 sec)

mysql> quit;
Bye

(Continued on next topic...)

  1. What Is the Command Line End User Interface - mysql?
  2. What Are the "mysql" Command Line Options?
  3. What Are the "mysql" Command Line Arguments?
  4. How Many SQL DDL Commands Are Supported by "mysql"?
  5. How Many SQL DML Commands Are Supported by "mysql"?
  6. What Are the Non-Standard SQL Commands Supported by "mysql"?
  7. How To Get Help Information from the Server?
  8. How To Run "mysql" Commands from a Batch File?
  9. How To Return Query Output in HTML Format?
  10. How To Return Query Output in XML Format?

MySQL Tutorials:

More...


Other Tutorials/FAQs:

More...


Related Resources:

More...


Selected Jobs:

More...