Rechercher dans le manuel MySQL
4.2.2.1 Using Options on the Command Line
Program options specified on the command line follow these rules:
Options are given after the command name.
An option argument begins with one dash or two dashes, depending on whether it is a short form or long form of the option name. Many options have both short and long forms. For example,
-?
and--help
are the short and long forms of the option that instructs a MySQL program to display its help message.Option names are case-sensitive.
-v
and-V
are both legal and have different meanings. (They are the corresponding short forms of the--verbose
and--version
options.)Some options take a value following the option name. For example,
-h localhost
or--host=localhost
indicate the MySQL server host to a client program. The option value tells the program the name of the host where the MySQL server is running.For a long option that takes a value, separate the option name and the value by an
=
sign. For a short option that takes a value, the option value can immediately follow the option letter, or there can be a space between:-hlocalhost
and-h localhost
are equivalent. An exception to this rule is the option for specifying your MySQL password. This option can be given in long form as--password=
or aspass_val
--password
. In the latter case (with no password value given), the program interactively prompts you for the password. The password option also may be given in short form as-p
or aspass_val
-p
. However, for the short form, if the password value is given, it must follow the option letter with no intervening space. The reason for this is that if a space follows the option letter, the program has no way to tell whether a following argument is supposed to be the password value or some other kind of argument. Consequently, the following two commands have two completely different meanings:mysql -ptest mysql -p test
The first command instructs mysql to use a password value of
test
, but specifies no default database. The second instructs mysql to prompt for the password value and to usetest
as the default database.Within option names, dash (
-
) and underscore (_
) may be used interchangeably. For example,--skip-grant-tables
and--skip_grant_tables
are equivalent. (However, the leading dashes cannot be given as underscores.)For options that take a numeric value, the value can be given with a suffix of
K
,M
, orG
to indicate a multiplier of 1024, 10242 or 10243. As of MySQL 8.0.14, a suffix can also beT
,P
, andE
to indicate a multiplier of 10244, 10245 or 10246. Suffix letters can be uppercase or lowercase.For example, the following command tells mysqladmin to ping the server 1024 times, sleeping 10 seconds between each ping:
mysqladmin --count=1K --sleep=10 ping
When specifying file names as option values, avoid the use of the
~
shell metacharacter because it might not be interpreted as you expect.
Option values that contain spaces must be quoted when given on
the command line. For example, the
--execute
(or -e
)
option can be used with mysql to pass SQL
statements to the server. When this option is used,
mysql executes the statements in the option
value and exits. The statements must be enclosed by quotation
marks. For example, you can use the following command to obtain
a list of user accounts:
shell> mysql -u root -p --execute="SELECT User, Host FROM mysql.user"
Enter password: ******
+------+-----------+
| User | Host |
+------+-----------+
| | gigan |
| root | gigan |
| | localhost |
| jon | localhost |
| root | localhost |
+------+-----------+
shell>
The long form (--execute
) is
followed by an equal sign (=
).
If you wish to use quoted values within a statement, you will either need to escape the inner quotation marks, or use a different type of quotation marks within the statement from those used to quote the statement itself. The capabilities of your command processor dictate your choices for whether you can use single or double quotation marks and the syntax for escaping quote characters. For example, if your command processor supports quoting with single or double quotation marks, you can use double quotation marks around the statement, and single quotation marks for any quoted values within the statement.
Multiple SQL statements may be passed in the option value on the command line, separated by semicolons:
shell> mysql -u root -p -e "SELECT VERSION();SELECT NOW()"
Enter password: ******
+------------+
| VERSION() |
+------------+
| 8.0.11 |
+------------+
+---------------------+
| NOW() |
+---------------------+
| 2019-05-17 11:43:57 |
+---------------------+
Deutsche Übersetzung
Sie haben gebeten, diese Seite auf Deutsch zu besuchen. Momentan ist nur die Oberfläche übersetzt, aber noch nicht der gesamte Inhalt.Wenn Sie mir bei Übersetzungen helfen wollen, ist Ihr Beitrag willkommen. Alles, was Sie tun müssen, ist, sich auf der Website zu registrieren und mir eine Nachricht zu schicken, in der Sie gebeten werden, Sie der Gruppe der Übersetzer hinzuzufügen, die Ihnen die Möglichkeit gibt, die gewünschten Seiten zu übersetzen. Ein Link am Ende jeder übersetzten Seite zeigt an, dass Sie der Übersetzer sind und einen Link zu Ihrem Profil haben.
Vielen Dank im Voraus.
Dokument erstellt 26/06/2006, zuletzt geändert 26/10/2018
Quelle des gedruckten Dokuments:https://www.gaudry.be/de/mysql-rf-command-line-options.html
Die Infobro ist eine persönliche Seite, deren Inhalt in meiner alleinigen Verantwortung liegt. Der Text ist unter der CreativeCommons-Lizenz (BY-NC-SA) verfügbar. Weitere Informationen auf die Nutzungsbedingungen und dem Autor.
Referenzen
Diese Verweise und Links verweisen auf Dokumente, die während des Schreibens dieser Seite konsultiert wurden, oder die zusätzliche Informationen liefern können, aber die Autoren dieser Quellen können nicht für den Inhalt dieser Seite verantwortlich gemacht werden.
Der Autor Diese Website ist allein dafür verantwortlich, wie die verschiedenen Konzepte und Freiheiten, die mit den Nachschlagewerken gemacht werden, hier dargestellt werden. Denken Sie daran, dass Sie mehrere Quellinformationen austauschen müssen, um das Risiko von Fehlern zu reduzieren.