- Learn MySQL
- MySQL - Home
- MySQL - Introduction
- MySQL - Installation
- MySQL - Administration
- MySQL - PHP Syntax
- MySQL - Connection
- MySQL - Create Database
- MySQL - Drop Database
- MySQL - Select Database
- MySQL - Data Types
- MySQL - Create Tables
- MySQL - Drop Tables
- MySQL - Insert Query
- MySQL - Select Query
- MySQL - Where Clause
- MySQL - Update Query
- MySQL - Delete Query
- MySQL - Like Clause
- MySQL - Sorting Results
- MySQL - Using Join
- MySQL - NULL Values
- MySQL - Regexps
- MySQL - Transactions
- MySQL - Alter Command
- MySQL - Indexes
- MySQL - Temporary Tables
- MySQL - Clone Tables
- MySQL - Database Info
- MySQL - Using Sequences
- MySQL - Handling Duplicates
- MySQL - SQL Injection
- MySQL - Database Export
- MySQL - Database Import
The MySQL Command-Line Client
The mysql is a simple SQL shell that has input line editing capabilities. It supports interactive and noninteractive usage. When it is used interactively, query results are presented in an ASCII-table format. When it is used noninteractively, like a filter, the result would be presented in tab-separated format.
The output format can be changed with the help of command options. If there are issues because of insufficient memory for large result sets, the --quick option can be used.
This forces the mysql to retrieve results from the server, a row at a time instead of retrieving the entire result set at once and buffering it in memory before it is being displayed. This is done by returning the result set with the help of the mysql_use_result() C API function which is present in the client/server library instead of mysql_store_result().
Using mysql is an easy task. It can be invoked from the prompt of the user’s command interpreter. It has been demonstrated below −
shell> mysql db_name
shell> mysql --user=user_name --password db_name
Enter password: your_password
Then an SQL statement can be typed, and can be ended with ;, \g, or \G.
Typing Control+C interrupts the current statement if there is such a statement, or cancels any partial input line if not.
SQL statements can be executed in a script file (or batch file). It has been shown below −
shell> mysql db_name < script.sql > output.tab
On Unix, the mysql client logs statements which are executed interactively to a history file.
- Related Articles
- MySQL command line client for Windows?
- Best Command Line HTTP Client for Linux
- MySQL query to discover current default database collation (via command line client)?
- How to see spaces in data when selecting with MySQL command line client?
- Rainbow Stream – An Advanced Command-line Twitter Client for Linux
- Connecting to MySQL database from the command line?
- Connect to MySQL database from command line
- How to repair MySQL tables from the command line?
- Using Options on the Command Line for MySQL programs?
- How to open MySQL command line on Windows10?
- How to upgrade MySQL server from command line?
- How can we return to windows command shell from MySQL command line tool?
- Avoid placing password on command line with MySQL Utilities?
- How to adjust display settings of MySQL command line?
- How to display records vertically in MySQL command line?