connecting needs a password to access the database. Note that this is a lowercase p.
-P n Specifies n as the number of the port to which the client should connect. Note that this is an uppercase P.
-? Displays a help message.

More options are available than are listed in Table 18.1, but these are the most common options. See the man page for mysql for more information on the available options.

CAUTION

Although mysql enables you to specify the password on the command line after the -p option, and thus enables you to avoid having to type the password at the prompt, you should never invoke the client this way. Doing so causes your password to display in the process list, and the process list can be accessed by any user on the system. This is a major security hole, so you should never give your password on the mysql command line.

You can access the MySQL server without specifying a database to use. After you log in, you use the help command to get a list of available commands, like this:

mysql> help

MySQL commands:

Note that all text commands must be first on line and end with ';'

help (h) Display this help.

? (?) Synonym for `help'.

clear (c) Clear command.

connect ( ) Reconnect to the server. Optional arguments are db and host.

edit (e) Edit command with $EDITOR.

ego (G) Send command to mysql server, display result vertically.

exit (q) Exit mysql. Same as quit.

go (g) Send command to mysql server.

nopager ( ) Disable pager, print to stdout.

notee ( ) Don't write into outfile.

pager (P) Set PAGER [to_pager]. Print the query results via PAGER.

print (p) Print current command.

quit (q) Quit mysql.

rehash (#) Rebuild completion hash.

source (.) Execute a SQL script file. Takes a file name as an argument.

status (s) Get status information from the server.

tee (T) Set outfile [to_outfile]. Append everything into given outfile.

use (u) Use another database. Takes database name as argument.

You can then access a database by using the use command and the name of a database that has been created (such as animals) and to which you are authorized to connect, like this:

mysql> use animals

Database changed

mysql>

The PostgreSQL Command-Line Client

You invoke the PostgreSQL command-line client with the command psql. Like mysql, psql can be invoked with the name of the database to which you would like to connect. Also like mysql, psql can take several options. These options are listed in Table 18.2.

TABLE 18.2 Command-Line Options to Use When Invoking psql

Option Action
-h hostname Connects to the remote host hostname (if the database server isn't located on the local system).
-p n Specifies n as the number of the port to which the client should connect. Note that this is a lowercase p.
-U username Connects to the database as the user username.
-W Prompts for a password after connecting to the database. In PostgreSQL 7 and later, password prompting is automatic if the server requests a password after a connection has been established.
-? Displays a help message.

Several more options are available in addition to those listed in Table 18.2. See the psql's man page for details on all the available options.

Добавить отзыв
ВСЕ ОТЗЫВЫ О КНИГЕ В ИЗБРАННОЕ

0

Вы можете отметить интересные вам фрагменты текста, которые будут доступны по уникальной ссылке в адресной строке браузера.

Отметить Добавить цитату