Connecting to the MySQL Server
For a client program to be able to connect to the MySQL server, it must use the proper connection
parameters, such as the name of the host where the server is running and the user name and
password of your MySQL account. Each connection parameter has a default value, but you can
override them as necessary using program options specified either on the command line or in an option
The examples here use the mysql client program, but the principles apply to other clients such as
mysqldump, mysqladmin, or mysqlshow.
This command invokes mysql without specifying any connection parameters explicitly:
Because there are no parameter options, the default values apply:
• The default host name is localhost. On Unix, this has a special meaning, as described later.
• The default user name is ODBC on Windows or your Unix login name on Unix.
• No password is sent if neither -p nor --password  is given.
• For mysql, the first nonoption argument is taken as the name of the default database. If there is no
such option, mysql does not select a default database.
To specify the host name and user name explicitly, as well as a password, supply appropriate options
on the command line:
shell mysql --host=localhost --user=myname --password=mypass mydb
shell mysql -h localhost -u myname -pmypass mydb
For password options, the password value is optional:
• If you use a -p or --password  option and specify the password value, there must be no
space between -p or --password=  and the password following it.
• If you use a -p or --password  option but do not specify the password value, the client
program prompts you to enter the password. The password is not displayed as you enter it. This is
more secure than giving the password on the command line. Other users on your system may be
able to see a password specified on the command line by executing a command such as ps auxw.
See Section 220.127.116.11, “End-User Guidelines for Password Security”.
... zobacz całą notatkę