Linux cli command mariadb
6 minute read
NAME 🖥️ mariadb 🖥️
the MariaDB command-line tool (mysql is now a symlink to mariadb)
SYNOPSIS
mysql [options] db_name
DESCRIPTION
mysql is a simple SQL shell (with GNU readline capabilities). It supports interactive and non-interactive use. When used interactively, query results are presented in an ASCII-table format. When used non-interactively (for example, as a filter), the result is presented in tab-separated format. The output format can be changed using command options.
If you have problems due to insufficient memory for large result sets, use the –quick option. This forces mysql to retrieve results from the server a row at a time rather than retrieving the entire result set and buffering it in memory before displaying it. This is done by returning the result set using the mysql_use_result() C API function in the client/server library rather than mysql_store_result().
Using mysql is very easy. Invoke it from the prompt of your command interpreter as follows:
shell> mysql db_name
Or:
shell> mysql –user=user_name –password=your_password db_name
Then type an SQL statement, end it with “;”, \g, or \G and press Enter.
Typing Control-C causes mysql to attempt to kill the current statement. If this cannot be done, or Control-C is typed again before the statement is killed, mysql exits.
You can execute SQL statements in a script file (batch file) like this:
shell> mysql db_name < script.sql > output.tab
MYSQL OPTIONS
mysql supports the following options, which can be specified on the command line or in the [mysql], [client], [client-server] or [client-mariadb] option file groups. mysql also supports the options for processing option files.
·
–help, -?, -I
Display a help message and exit.
·
–abort-source-on-error
Abort ‘source filename’ operations in case of errors.
·
–auto-rehash
Enable automatic rehashing. This option is on by default, which enables database, table, and column name completion. Use –disable-auto-rehash, –no-auto-rehash, or –skip-auto-rehash to disable rehashing. That causes mysql to start faster, but you must issue the rehash command if you want to use name completion.
To complete a name, enter the first part and press Tab. If the name is unambiguous, mysql completes it. Otherwise, you can press Tab again to see the possible names that begin with what you have typed so far. Completion does not occur if there is no default database.
·
–auto-vertical-output
Automatically switch to vertical output mode if the result is wider than the terminal width.
·
–batch, -B
Print results using tab as the column separator, with each row on a new line. With this option, mysql does not use the history file.
Batch mode results in nontabular output format and escaping of special characters. Escaping may be disabled by using raw mode; see the description for the –raw option.
·
–binary-mode
Binary mode allows certain character sequences to be processed as data that would otherwise be treated with a special meaning by the parser. Specifically, this switch turns off parsing of all client commands except \C and DELIMITER in non-interactive mode (i.e., when binary mode is combined with either 1) piped input, 2) the –batch mysql option, or 3) the ‘source’ command). Also, in binary mode, occurrences of ’ ’ and ASCII ‘�’ are preserved within strings, whereas by default, ’ ’ is translated to ' ’ and ‘�’ is disallowed in user input.
·
**–character-sets-dir=**path
The directory where character sets are installed.
·
–column-names
Write column names in results.
·
–column-type-info, -m
Display result set metadata.
·
–comments, -c
Whether to preserve comments in statements sent to the server. The default is –skip-comments (discard comments), enable with –comments (preserve comments).
·
–compress, -C
Compress all information sent between the client and the server if both support compression.
·
**–connect-timeout=**seconds
Set the number of seconds before connection timeout. (Default value is 0.)
·
**–database=**db_name, -D db_name
The database to use.
·
–debug[=debug_options], -# [debug_options]
Write a debugging log. A typical debug_options string is ’d:t:o,file_name’. The default is ’d:t:o,/tmp/mysql.trace’.
·
–debug-check
Print some debugging information when the program exits.
·
–debug-info, -T
Prints debugging information and memory and CPU usage statistics when the program exits.
·
**–default-auth=**name
Default authentication client-side plugin to use.
·
**–default-character-set=**charset_name
Use charset_name as the default character set for the client and connection.
A common issue that can occur when the operating system uses utf8 or another multi-byte character set is that output from the mysql client is formatted incorrectly, due to the fact that the MariaDB client uses the latin1 character set by default. You can usually fix such issues by using this option to force the client to use the system character set instead.
·
**–defaults-extra-file=**filename
Set filename as the file to read default options from after the global defaults files has been read. Must be given as first option.
·
**–defaults-file=**filename
Set filename as the file to read default options from, override global defaults files. Must be given as first option.
·
**–defaults-group-suffix=**suffix
In addition to the groups named on the command line, read groups that have the given suffix.
·
**–delimiter=**str
Set the statement delimiter. The default is the semicolon character (“;”).
·
–disable-named-commands
Disable named commands. Use the \ form only, or use named commands only at the beginning of a line ending with a semicolon (“;”). mysql starts with this option enabled by default. However, even with this option, long-format commands still work from the first line. See the section called “MYSQL COMMANDS”.
·
–enable-cleartext-plugin
Obsolete option. Exists only for MySQL compatibility.
·
**–execute=**statement, -e statement
Execute the statement and quit. Disables –force and history file. The default output format is like that produced with –batch.
·
–force, -f
Continue even if an SQL error occurs. Sets –abort-source-on-error to 0.
·
**–host=**host_name, -h host_name
Connect to the MariaDB server on the given host.
·
–html, -H
Produce HTML output.
·
–ignore-spaces, -i
Ignore spaces after function names. Allows one to have spaces (including tab characters and new line characters) between function name and ‘(’. The drawback is that this causes built in functions to become reserved words.
·
**–init-command=**str
SQL Command to execute when connecting to the MariaDB server. Will automatically be re-executed when reconnecting.
·
–line-numbers
Write line numbers for errors. Disable this with –skip-line-numbers.
·
–local-infile[={0|1}]
Enable or disable LOCAL capability for LOAD DATA INFILE. With no value, the option enables LOCAL. The option may be given as –local-infile=0 or –local-infile=1 to explicitly disable or enable LOCAL. Enabling LOCAL has no effect if the server does not also support it.
·
**–max-allowed-packet=**num
Set the maximum packet length to send to or receive from the server. (Default value is 16MB, largest 1GB.)
·
**–max-join-size=**num
Set the automatic limit for rows in a join when using –safe-updates. (Default value is 1,000,000.)
·
–named-commands, -G
Enable named mysql commands. Long-format commands are allowed, not just short-format commands. For example, quit and \q both are recognized. Use –skip-named-commands to disable named commands. See the section called “MYSQL COMMANDS”. Disabled by default.
·
·
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
█║▌│║█║▌★ KALI ★ PARROT ★ DEBIAN 🔴 PENTESTING ★ HACKING ★ █║▌│║█║▌
██╗ ██╗ ██████╗ ██████╗ ██╗ ██╗███████╗██████╗
████████╗██╔══██╗██╔═══██╗╚██╗██╔╝██╔════╝██╔══██╗
╚██╔═██╔╝██║ ██║██║ ██║ ╚███╔╝ █████╗ ██║ ██║
████████╗██║ ██║██║ ██║ ██╔██╗ ██╔══╝ ██║ ██║
╚██╔═██╔╝██████╔╝╚██████╔╝██╔╝ ██╗███████╗██████╔╝
╚═╝ ╚═╝ ╚═════╝ ╚═════╝ ╚═╝ ╚═╝╚══════╝╚═════╝
█║▌│║█║▌ WITH COMMANDLINE-KUNGFU POWER █║▌│║█║▌
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
Feedback
Was this page helpful?
Glad to hear it! Please tell us how we can improve.
Sorry to hear that. Please tell us how we can improve.