- How to execute os command from mysql5 for windows?
- 2 Answers 2
- Командная строка MySQL
- Подключение к MySQL через консоль
- Полезные команды MySQL
- Управление базами данных
- Работа с пользователями
- Исправление и оптимизация баз данных в MySQL
- Бэкап MySQL из командной строки
- Mysql execute windows command
- Mysql execute windows command
- Mysql execute windows command
How to execute os command from mysql5 for windows?
In mysql5.X database on Linux the command system or ! can be used to run bash command from database command line.
Are there equivalent commands as system or ! in mysql5.X database for Windows?
The Windows command does not work!
2 Answers 2
In mysql5.X database (for Linux), command «system» or «!» can be used to run bash command from database command Linux.
This is not SQL command. This is command-line client command. And it will work only in CLI or another client which supports this command. It will NOT work if you try to send in to MySQL server directly by any technique.
Is there a equivalent command as «system» or «!» in mysql5.X database (for Windows)?
If used CLI version supports this command then it will work otherwise no. This not depends on MySQL server version.
Windows is not the same operating system, and as such the names of the tools internally are, in many cases, completely different, like ls vs. dir .
ipconfig is a Linux thing but it’s also not necessarily a given that it’ll be present. On more modern distributions the ip command is becoming the default. That’s to say you’ll need to lookup what the command you’re going to run is, and verify that with testing.
You’ll need to run the command appropriate for the environment you’re running on, whatever that is.
That being said, running shell commands inside of the mysql> shell is highly irregular and should be a last resort. Doing it can be viewed as highly suspicious and may be restricted.
Командная строка MySQL
Небольшая памятка по работе с сервером MySQL из командной строки.
Подключение к MySQL через консоль
Получить информацию об установленной версии MySQL
Для подключения к mysql в консоли наберите команду
- h — хост c MySQL. Если подключаемся с локальной машины, параметр можно опустить
- u — имя пользователя MySQL (root или другой пользователь MySQL)
- p — пароль, который будет предложено ввести после нажатия enter
Приглашение командной строки изменится, это значит, сервер MySQL ждёт от вас команд.
Запросы должны оканчиваться точкой с запятой. Длинные запросы удобно разбивать enter-ом для перехода на новую строку, а после полного написания запроса поставить точку с запятой и выполнить его.
Для отключения от MySQL нужно написать exit или (в unix-системах) нажать комбинацию клавиш ctrl+с.
Для вывода всех баз данных на сервере используйте команду show databases.
Выберите нужную базу данных командой use.
Теперь можно вводить запросы.
Чтобы подключиться к MySQL и сразу выбрать нужную базу
Полезные команды MySQL
Показать все таблицы выбранной базы данных в текущей БД.
Показать все таблицы базы данных db_name.
Показать список столбцов в таблице table_name в текущей БД
Показать список столбцов в таблице table_name из БД db_name
Вывести структуру нужной таблицы
Показать структуру таблицы, будет выведен sql-запрос на её создание через «CREATE TABLE».
Вывести значения системных переменных.
Показать список выполняющихся в настоящий момент запросов.
Общая статистика MySQL.
Статистика по всем таблицам в базе db_name.
Что бы выполнять запросы к MySQL из консоли, не всегда требуется предварительно подключаться к mysql. Параметр -e позволяет исполнить команду, вывести результат на экран, после чего отключиться от сервера MySQL. Например, можно вывести список таблиц базы данных.
Управление базами данных
Создание базы данных из консоли сервера
Удаление базы данных из консоли сервера
Создание базы данных db_name из консоли MySQL
Удаление базы данных db_name из консоли MySQL
Замена в поле одной подстроки на другую
Работа с пользователями
Вывести список пользователей
Показать список прав пользователя user
Создать нового пользователя
host — здесь имя хоста, доменное имя или ip адрес, с которого пользователь сможет подключаться к серверу, например user@localhost.
Чтобы создаваемый пользователь смог подключаться к серверу MySQL с любого IP адреса или хоста (за исключением localhost), можно использовать символ процента, вот так
Чтобы разрешрешить пользователю подключаться вообще со всех хостов, придётся создать для него две учётные записи.
Добавить указанные привилегии для таблиц БД db_name пользователю user@localhost
Чтобы изменить права пользователю, иногда удобно сначала сбросить все права
А затем установить нужные с помощью GRANT, как было показано выше.
Добавить все привилегии для таблиц БД db_name пользователю user@localhost
Удаление привилегий пользователя user@localhost для БД db_name:
Сделать из пользователя суперпользователя и дать полный доступ ко всем БД на сервере
Удалить пользователя user@localhost
Изменить пароль пользователя в консоли MySQL
Установить пароль для пользователя user в консоли сервера.
Исправление и оптимизация баз данных в MySQL
Чтобы исправить ошибки в поврежденной таблице, в консоли MySQL выполните:
Если же в БД много поврежденных таблиц можно воспользоваться командой mysqlcheck.
Проверить db_name на ошибки.
Восстановление и оптимизация всех БД
- p – использовать пароль
- -A, —all-databases – проверять все базы данных
- -o, —optimize – оптимизировать
- -r, —repair – восстанавливать повреждённые
- —auto-repair – автоматическое восстановление
Бэкап MySQL из командной строки
Экспорт базы MySQL
Дамп нескольких баз
Дамп всех баз на сервере
Дамп только структуры базы, без данных
Дамп структуры одной таблицы mysql, без данных:
Развернуть базу данных MySQL из дампа
На этом всё. Но вы можете помочь проекту. Даже небольшая сумма поможет нам писать больше полезных статей.
Если статья помогла или понравилась, пожалуйста поделитесь ей в соцсетях.
Mysql execute windows command
The MySQL server can be started manually from the command line. This can be done on any version of Windows.
To start the mysqld server from the command line, you should start a console window (or “ DOS window ” ) and enter this command:
The path to mysqld may vary depending on the install location of MySQL on your system.
You can stop the MySQL server by executing this command:
If the MySQL root user account has a password, you need to invoke mysqladmin with the -p option and supply the password when prompted.
This command invokes the MySQL administrative utility mysqladmin to connect to the server and tell it to shut down. The command connects as the MySQL root user, which is the default administrative account in the MySQL grant system.
Users in the MySQL grant system are wholly independent from any operating system users under Microsoft Windows.
If mysqld doesn’t start, check the error log to see whether the server wrote any messages there to indicate the cause of the problem. By default, the error log is located in the C:\Program Files\MySQL\MySQL Server 5.7\data directory. It is the file with a suffix of .err , or may be specified by passing in the —log-error option. Alternatively, you can try to start the server with the —console option; in this case, the server may display some useful information on the screen to help solve the problem.
The last option is to start mysqld with the —standalone and —debug options. In this case, mysqld writes a log file C:\mysqld.trace that should contain the reason why mysqld doesn’t start. See The DBUG Package.
Use mysqld —verbose —help to display all the options that mysqld supports.
Mysql execute windows command
The mysql client typically is used interactively, like this:
However, it is also possible to put your SQL statements in a file and then tell mysql to read its input from that file. To do so, create a text file text_file that contains the statements you wish to execute. Then invoke mysql as shown here:
If you place a USE db_name statement as the first statement in the file, it is unnecessary to specify the database name on the command line:
If you are already running mysql , you can execute an SQL script file using the source command or \. command:
Sometimes you may want your script to display progress information to the user. For this you can insert statements like this:
The statement shown outputs .
You can also invoke mysql with the —verbose option, which causes each statement to be displayed before the result that it produces.
mysql ignores Unicode byte order mark (BOM) characters at the beginning of input files. Previously, it read them and sent them to the server, resulting in a syntax error. Presence of a BOM does not cause mysql to change its default character set. To do that, invoke mysql with an option such as —default-character-set=utf8 .
For more information about batch mode, see Section 3.5, “Using mysql in Batch Mode”.
Mysql execute windows command
mysql supports the following options, which can be specified on the command line or in the [mysql] and [client] groups of an option file. For information about option files used by MySQL programs, see Section 4.2.2.2, “Using Option Files”.
Table 4.12 mysql Client Options
Option Name | Description | Introduced | Deprecated |
---|---|---|---|
—auto-rehash | Enable automatic rehashing | ||
—auto-vertical-output | Enable automatic vertical result set display | ||
—batch | Do not use history file | ||
—binary-as-hex | Display binary values in hexadecimal notation | 5.7.19 | |
—binary-mode | Disable \r\n — to — \n translation and treatment of \0 as end-of-query | ||
—bind-address | Use specified network interface to connect to MySQL Server | ||
—character-sets-dir | Directory where character sets are installed | ||
—column-names | Write column names in results | ||
—column-type-info | Display result set metadata | ||
—comments | Whether to retain or strip comments in statements sent to the server | ||
—compress | Compress all information sent between client and server | ||
—connect-expired-password | Indicate to server that client can handle expired-password sandbox mode | ||
—connect-timeout | Number of seconds before connection timeout | ||
—database | The database to use | ||
—debug | Write debugging log; supported only if MySQL was built with debugging support | ||
—debug-check | Print debugging information when program exits | ||
—debug-info | Print debugging information, memory, and CPU statistics when program exits | ||
—default-auth | Authentication plugin to use | ||
—default-character-set | Specify default character set | ||
—defaults-extra-file | Read named option file in addition to usual option files | ||
—defaults-file | Read only named option file | ||
—defaults-group-suffix | Option group suffix value | ||
—delimiter | Set the statement delimiter | ||
—enable-cleartext-plugin | Enable cleartext authentication plugin | ||
—execute | Execute the statement and quit | ||
—force | Continue even if an SQL error occurs | ||
—get-server-public-key | Request RSA public key from server | 5.7.23 | |
—help | Display help message and exit | ||
—histignore | Patterns specifying which statements to ignore for logging | ||
—host | Host on which MySQL server is located | ||
—html | Produce HTML output | ||
—ignore-spaces | Ignore spaces after function names | ||
—init-command | SQL statement to execute after connecting | ||
—line-numbers | Write line numbers for errors | ||
—local-infile | Enable or disable for LOCAL capability for LOAD DATA | ||
—login-path | Read login path options from .mylogin.cnf | ||
—max-allowed-packet | Maximum packet length to send to or receive from server | ||
—max-join-size | The automatic limit for rows in a join when using —safe-updates | ||
—named-commands | Enable named mysql commands | ||
—net-buffer-length | Buffer size for TCP/IP and socket communication | ||
—no-auto-rehash | Disable automatic rehashing | ||
—no-beep | Do not beep when errors occur | ||
—no-defaults | Read no option files | ||
—one-database | Ignore statements except those for the default database named on the command line | ||
—pager | Use the given command for paging query output | ||
—password | Password to use when connecting to server | ||
—pipe | Connect to server using named pipe (Windows only) | ||
—plugin-dir | Directory where plugins are installed | ||
—port | TCP/IP port number for connection | ||
—print-defaults | Print default options | ||
—prompt | Set the prompt to the specified format | ||
—protocol | Transport protocol to use | ||
—quick | Do not cache each query result | ||
—raw | Write column values without escape conversion | ||
—reconnect | If the connection to the server is lost, automatically try to reconnect | ||
—safe-updates, —i-am-a-dummy | Allow only UPDATE and DELETE statements that specify key values | ||
—secure-auth | Do not send passwords to server in old (pre-4.1) format | Yes | |
—select-limit | The automatic limit for SELECT statements when using —safe-updates | ||
—server-public-key-path | Path name to file containing RSA public key | ||
—shared-memory-base-name | Shared-memory name for shared-memory connections (Windows only) | ||
—show-warnings | Show warnings after each statement if there are any | ||
—sigint-ignore | Ignore SIGINT signals (typically the result of typing Control+C) | ||
—silent | Silent mode | ||
—skip-auto-rehash | Disable automatic rehashing | ||
—skip-column-names | Do not write column names in results | ||
—skip-line-numbers | Skip line numbers for errors | ||
—skip-named-commands | Disable named mysql commands | ||
—skip-pager | Disable paging | ||
—skip-reconnect | Disable reconnecting | ||
—socket | Unix socket file or Windows named pipe to use | ||
—ssl | Enable connection encryption | ||
—ssl-ca | File that contains list of trusted SSL Certificate Authorities | ||
—ssl-capath | Directory that contains trusted SSL Certificate Authority certificate files | ||
—ssl-cert | File that contains X.509 certificate | ||
—ssl-cipher | Permissible ciphers for connection encryption | ||
—ssl-crl | File that contains certificate revocation lists | ||
—ssl-crlpath | Directory that contains certificate revocation-list files | ||
—ssl-key | File that contains X.509 key | ||
—ssl-mode | Desired security state of connection to server | 5.7.11 | |
—ssl-verify-server-cert | Verify host name against server certificate Common Name identity | ||
—syslog | Log interactive statements to syslog | ||
—table | Display output in tabular format | ||
—tee | Append a copy of output to named file | ||
—tls-version | Permissible TLS protocols for encrypted connections | 5.7.10 | |
—unbuffered | Flush the buffer after each query | ||
—user | MySQL user name to use when connecting to server | ||
—verbose | Verbose mode | ||
—version | Display version information and exit | ||
—vertical | Print query output rows vertically (one line per column value) | ||
—wait | If the connection cannot be established, wait and retry instead of aborting | ||
—xml | Produce XML output |
Display a help message and exit.
Enable automatic rehashing. This option is on by default, which enables database, table, and column name completion. Use —disable-auto-rehash to disable rehashing. That causes mysql to start faster, but you must issue the rehash command or its \# shortcut 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.
This feature requires a MySQL client that is compiled with the readline library. Typically, the readline library is not available on Windows.
Cause result sets to be displayed vertically if they are too wide for the current window, and using normal tabular format otherwise. (This applies to statements terminated by ; or \G .)
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.
When this option is given, mysql displays binary data using hexadecimal notation ( 0x value ). This occurs whether the overall output display format is tabular, vertical, HTML, or XML.
—binary-as-hex when enabled affects display of all binary strings, including those returned by functions such as CHAR() and UNHEX() . The following example demonistrates this using the ASCII code for A (65 decimal, 41 hexadecimal):
To write a binary string expression so that it displays as a character string regardless of whether —binary-as-hex is enabled, use these techniques:
The CHAR() function has a USING charset clause:
More generally, use CONVERT() to convert an expression to a given character set:
This option was added in MySQL 5.7.19.
This option helps when processing mysqlbinlog output that may contain BLOB values. By default, mysql translates \r\n in statement strings to \n and interprets \0 as the statement terminator. —binary-mode disables both features. It also disables all mysql commands except charset and delimiter in noninteractive mode (for input piped to mysql or loaded using the source command).
On a computer having multiple network interfaces, use this option to select which interface to use for connecting to the MySQL server.
The directory where character sets are installed. See Section 10.15, “Character Set Configuration”.
Write column names in results.
Display result set metadata. This information corresponds to the contents of C API MYSQL_FIELD data structures. See C API Basic Data Structures.
Whether to strip or preserve comments in statements sent to the server. The default is —skip-comments (strip comments), enable with —comments (preserve comments).
In MySQL 5.7, the mysql client always passes optimizer hints to the server, regardless of whether this option is given. To ensure that optimizer hints are not stripped if you are using an older version of the mysql client with a version of the server that understands optimizer hints, invoke mysql with the —comments option.
Comment stripping is deprecated as of MySQL 5.7.20. You should expect this feature and the options to control it to be removed in a future MySQL release.
Compress all information sent between the client and the server if possible. See Section 4.2.6, “Connection Compression Control”.
Indicate to the server that the client can handle sandbox mode if the account used to connect has an expired password. This can be useful for noninteractive invocations of mysql because normally the server disconnects noninteractive clients that attempt to connect using an account with an expired password. (See Section 6.2.12, “Server Handling of Expired Passwords”.)
The number of seconds before connection timeout. (Default value is 0 .)
The database to use. This is useful primarily in an option file.
Write a debugging log. A typical debug_options string is d:t:o, file_name . The default is d:t:o,/tmp/mysql.trace .
This option is available only if MySQL was built using WITH_DEBUG . MySQL release binaries provided by Oracle are not built using this option.
Print some debugging information when the program exits.
This option is available only if MySQL was built using WITH_DEBUG . MySQL release binaries provided by Oracle are not built using this option.
Print debugging information and memory and CPU usage statistics when the program exits.
This option is available only if MySQL was built using WITH_DEBUG . MySQL release binaries provided by Oracle are not built using this option.
A hint about which client-side authentication plugin to use. See Section 6.2.13, “Pluggable Authentication”.
Use charset_name as the default character set for the client and connection.
This option can be useful if the operating system uses one character set and the mysql client by default uses another. In this case, output may be formatted incorrectly. You can usually fix such issues by using this option to force the client to use the system character set instead.
Read this option file after the global option file but (on Unix) before the user option file. If the file does not exist or is otherwise inaccessible, an error occurs. If file_name is not an absolute path name, it is interpreted relative to the current directory.
For additional information about this and other option-file options, see Section 4.2.2.3, “Command-Line Options that Affect Option-File Handling”.
Use only the given option file. If the file does not exist or is otherwise inaccessible, an error occurs. If file_name is not an absolute path name, it is interpreted relative to the current directory.
Exception: Even with —defaults-file , client programs read .mylogin.cnf .
For additional information about this and other option-file options, see Section 4.2.2.3, “Command-Line Options that Affect Option-File Handling”.
Read not only the usual option groups, but also groups with the usual names and a suffix of str . For example, mysql normally reads the [client] and [mysql] groups. If this option is given as —defaults-group-suffix=_other , mysql also reads the [client_other] and [mysql_other] groups.
For additional information about this and other option-file options, see Section 4.2.2.3, “Command-Line Options that Affect Option-File Handling”.
Set the statement delimiter. The default is the semicolon character ( ; ).
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 Section 4.5.1.2, “mysql Client Commands”.
Enable the mysql_clear_password cleartext authentication plugin. (See Section 6.4.1.6, “Client-Side Cleartext Pluggable Authentication”.)
Execute the statement and quit. The default output format is like that produced with —batch . See Section 4.2.2.1, “Using Options on the Command Line”, for some examples. With this option, mysql does not use the history file.
Continue even if an SQL error occurs.
Request from the server the public key required for RSA key pair-based password exchange. This option applies to clients that authenticate with the caching_sha2_password authentication plugin. For that plugin, the server does not send the public key unless requested. This option is ignored for accounts that do not authenticate with that plugin. It is also ignored if RSA-based password exchange is not used, as is the case when the client connects to the server using a secure connection.
If —server-public-key-path= file_name is given and specifies a valid public key file, it takes precedence over —get-server-public-key .
For information about the caching_sha2_password plugin, see Section 6.4.1.4, “Caching SHA-2 Pluggable Authentication”.
The —get-server-public-key option was added in MySQL 5.7.23.
A list of one or more colon-separated patterns specifying statements to ignore for logging purposes. These patterns are added to the default pattern list ( «*IDENTIFIED*:*PASSWORD*» ). The value specified for this option affects logging of statements written to the history file, and to syslog if the —syslog option is given. For more information, see Section 4.5.1.3, “mysql Client Logging”.
Connect to the MySQL server on the given host.
Produce HTML output.
Ignore spaces after function names. The effect of this is described in the discussion for the IGNORE_SPACE SQL mode (see Section 5.1.10, “Server SQL Modes”).
SQL statement to execute after connecting to the server. If auto-reconnect is enabled, the statement is executed again after reconnection occurs.
Write line numbers for errors. Disable this with —skip-line-numbers .
By default, LOCAL capability for LOAD DATA is determined by the default compiled into the MySQL client library. To enable or disable LOCAL data loading explicitly, use the —local-infile option. When given with no value, the option enables LOCAL data loading. When given as —local-infile=0 or —local-infile=1 , the option disables or enables LOCAL data loading.
Successful use of LOCAL load operations within mysql also requires that the server permits local loading; see Section 6.1.6, “Security Considerations for LOAD DATA LOCAL”
Read options from the named login path in the .mylogin.cnf login path file. A “ login path ” is an option group containing options that specify which MySQL server to connect to and which account to authenticate as. To create or modify a login path file, use the mysql_config_editor utility. See Section 4.6.6, “mysql_config_editor — MySQL Configuration Utility”.
For additional information about this and other option-file options, see Section 4.2.2.3, “Command-Line Options that Affect Option-File Handling”.
The maximum size of the buffer for client/server communication. The default is 16MB, the maximum is 1GB.
The automatic limit for rows in a join when using —safe-updates . (Default value is 1,000,000.)
Enable named mysql commands. Long-format commands are permitted, not just short-format commands. For example, quit and \q both are recognized. Use —skip-named-commands to disable named commands. See Section 4.5.1.2, “mysql Client Commands”.
The buffer size for TCP/IP and socket communication. (Default value is 16KB.)
This has the same effect as —skip-auto-rehash . See the description for —auto-rehash .
Do not beep when errors occur.
Do not read any option files. If program startup fails due to reading unknown options from an option file, —no-defaults can be used to prevent them from being read.
The exception is that the .mylogin.cnf file is read in all cases, if it exists. This permits passwords to be specified in a safer way than on the command line even when —no-defaults is used. To create .mylogin.cnf , use the mysql_config_editor utility. See Section 4.6.6, “mysql_config_editor — MySQL Configuration Utility”.
For additional information about this and other option-file options, see Section 4.2.2.3, “Command-Line Options that Affect Option-File Handling”.
Ignore statements except those that occur while the default database is the one named on the command line. This option is rudimentary and should be used with care. Statement filtering is based only on USE statements.
Initially, mysql executes statements in the input because specifying a database db_name on the command line is equivalent to inserting USE db_name at the beginning of the input. Then, for each USE statement encountered, mysql accepts or rejects following statements depending on whether the database named is the one on the command line. The content of the statements is immaterial.
Suppose that mysql is invoked to process this set of statements:
The DELETE statement is executed because the default database is db1 , even though the statement names a table in a different database.
The DROP TABLE and CREATE TABLE statements are not executed because the default database is not db1 , even though the statements name a table in db1 .
The INSERT and CREATE TABLE statements are executed because the default database is db1 , even though the CREATE TABLE statement names a table in a different database.
Use the given command for paging query output. If the command is omitted, the default pager is the value of your PAGER environment variable. Valid pagers are less , more , cat [> filename] , and so forth. This option works only on Unix and only in interactive mode. To disable paging, use —skip-pager . Section 4.5.1.2, “mysql Client Commands”, discusses output paging further.
The password of the MySQL account used for connecting to the server. The password value is optional. If not given, mysql prompts for one. If given, there must be no space between —password= or -p and the password following it. If no password option is specified, the default is to send no password.
Specifying a password on the command line should be considered insecure. To avoid giving the password on the command line, use an option file. See Section 6.1.2.1, “End-User Guidelines for Password Security”.
To explicitly specify that there is no password and that mysql should not prompt for one, use the —skip-password option.
On Windows, connect to the server using a named pipe. This option applies only if the server was started with the named_pipe system variable enabled to support named-pipe connections. In addition, the user making the connection must be a member of the Windows group specified by the named_pipe_full_access_group system variable.
The directory in which to look for plugins. Specify this option if the —default-auth option is used to specify an authentication plugin but mysql does not find it. See Section 6.2.13, “Pluggable Authentication”.
For TCP/IP connections, the port number to use.
Print the program name and all options that it gets from option files.
For additional information about this and other option-file options, see Section 4.2.2.3, “Command-Line Options that Affect Option-File Handling”.
Set the prompt to the specified format. The default is mysql> . The special sequences that the prompt can contain are described in Section 4.5.1.2, “mysql Client Commands”.
The transport protocol to use for connecting to the server. It is useful when the other connection parameters normally result in use of a protocol other than the one you want. For details on the permissible values, see Section 4.2.5, “Connection Transport Protocols”.
Do not cache each query result, print each row as it is received. This may slow down the server if the output is suspended. With this option, mysql does not use the history file.
For tabular output, the “ boxing ” around columns enables one column value to be distinguished from another. For nontabular output (such as is produced in batch mode or when the —batch or —silent option is given), special characters are escaped in the output so they can be identified easily. Newline, tab, NUL , and backslash are written as \n , \t , \0 , and \\ . The —raw option disables this character escaping.
The following example demonstrates tabular versus nontabular output and the use of raw mode to disable escaping:
If the connection to the server is lost, automatically try to reconnect. A single reconnect attempt is made each time the connection is lost. To suppress reconnection behavior, use —skip-reconnect .
If this option is enabled, UPDATE and DELETE statements that do not use a key in the WHERE clause or a LIMIT clause produce an error. In addition, restrictions are placed on SELECT statements that produce (or are estimated to produce) very large result sets. If you have set this option in an option file, you can use —skip-safe-updates on the command line to override it. For more information about this option, see Using Safe-Updates Mode (—safe-updates).
Do not send passwords to the server in old (pre-4.1) format. This prevents connections except for servers that use the newer password format.
As of MySQL 5.7.5, this option is deprecated; expect it to be removed in a future MySQL release. It is always enabled and attempting to disable it ( —skip-secure-auth , —secure-auth=0 ) produces an error. Before MySQL 5.7.5, this option is enabled by default but can be disabled.
Passwords that use the pre-4.1 hashing method are less secure than passwords that use the native password hashing method and should be avoided. Pre-4.1 passwords are deprecated and support for them was removed in MySQL 5.7.5. For account upgrade instructions, see Section 6.4.1.3, “Migrating Away from Pre-4.1 Password Hashing and the mysql_old_password Plugin”.
The automatic limit for SELECT statements when using —safe-updates . (Default value is 1,000.)
The path name to a file in PEM format containing a client-side copy of the public key required by the server for RSA key pair-based password exchange. This option applies to clients that authenticate with the sha256_password or caching_sha2_password authentication plugin. This option is ignored for accounts that do not authenticate with one of those plugins. It is also ignored if RSA-based password exchange is not used, as is the case when the client connects to the server using a secure connection.
If —server-public-key-path= file_name is given and specifies a valid public key file, it takes precedence over —get-server-public-key .
For sha256_password , this option applies only if MySQL was built using OpenSSL.
On Windows, the shared-memory name to use for connections made using shared memory to a local server. The default value is MYSQL . The shared-memory name is case-sensitive.
This option applies only if the server was started with the shared_memory system variable enabled to support shared-memory connections.
Cause warnings to be shown after each statement if there are any. This option applies to interactive and batch mode.
Ignore SIGINT signals (typically the result of typing Control+C ).
Without this option, typing Control+C interrupts the current statement if there is one, or cancels any partial input line otherwise.
Silent mode. Produce less output. This option can be given multiple times to produce less and less output.
This option 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.
Do not write column names in results.
Do not write line numbers for errors. Useful when you want to compare result files that include error messages.
For connections to localhost , the Unix socket file to use, or, on Windows, the name of the named pipe to use.
On Windows, this option applies only if the server was started with the named_pipe system variable enabled to support named-pipe connections. In addition, the user making the connection must be a member of the Windows group specified by the named_pipe_full_access_group system variable.
Options that begin with —ssl specify whether to connect to the server using encryption and indicate where to find SSL keys and certificates. See Command Options for Encrypted Connections.
This option causes mysql to send interactive statements to the system logging facility. On Unix, this is syslog ; on Windows, it is the Windows Event Log. The destination where logged messages appear is system dependent. On Linux, the destination is often the /var/log/messages file.
Here is a sample of output generated on Linux by using —syslog . This output is formatted for readability; each logged message actually takes a single line.
Display output in table format. This is the default for interactive use, but can be used to produce table output in batch mode.
Append a copy of output to the given file. This option works only in interactive mode. Section 4.5.1.2, “mysql Client Commands”, discusses tee files further.
The permissible TLS protocols for encrypted connections. The value is a list of one or more comma-separated protocol names. The protocols that can be named for this option depend on the SSL library used to compile MySQL. For details, see Section 6.3.2, “Encrypted Connection TLS Protocols and Ciphers”.
This option was added in MySQL 5.7.10.
Flush the buffer after each query.
The user name of the MySQL account to use for connecting to the server.
Verbose mode. Produce more output about what the program does. This option can be given multiple times to produce more and more output. (For example, -v -v -v produces table output format even in batch mode.)
Display version information and exit.
Print query output rows vertically (one line per column value). Without this option, you can specify vertical output for individual statements by terminating them with \G .
If the connection cannot be established, wait and retry instead of aborting.
Produce XML output.
The XML output also uses an XML namespace, as shown here: