This section describes use of command-line options to specify how to establish connections to the MySQL server, for clients such as mysql  or mysqldump . For information on establishing connections using URI- like connection strings or key-value pairs, for clients such as MySQL Shell, see Section 4.2.5, “Connecting to the Server Using URI-Like Strings or Key-Value Pairs” . For additional information if you are unable to connect, see Section 6.2.21, “Troubleshooting Problems Connecting to MySQL” . 

For a client program 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 default values as necessary using program options specified either on the command line or in an option file. 

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 explicit connection parameters: 

mysql 

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 because neither --password  nor -p  is given. 

•For mysql , the first nonoption argument is taken as the name of the default database. Because there is no such argument, mysql  selects no default database. 

To specify the host name and user name explicitly, as well as a password, supply appropriate options on the command line. To select a default database, add a database-name argument. Examples: 

mysql --host=localhost --user=myname --password= password  mydb mysql -h localhost -u myname -p password  mydb 

For password options, the password value is optional: 

•If you use a --password  or -p  option and specify a password value, there must be no space  between --password=  or -p  and the password following it. 

•If you use --password  or -p  but do not specify a 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, which might enable other users on your system to see the password line by executing a command such as ps . See Section 6.1.2.1, “End-User Guidelines for Password Security” . 

•To explicitly specify that there is no password and that the client program should not prompt for one, use the --skip-password  option. 

As just mentioned, including the password value on the command line is a security risk. To avoid this risk, specify the --password  or -p  option without any following password value: 

mysql --host=localhost --user=myname --password mydb mysql -h localhost -u myname -p mydb 

When the --password  or -p  option is given with no password value, the client program prints a prompt and waits for you to enter the password. (In these examples, mydb  is not  interpreted as a password because it is separated from the preceding password option by a space.) 

On some systems, the library routine that MySQL uses to prompt for a password automatically limits the password to eight characters. That limitation is a property of the system library, not MySQL. Internally, MySQL does not have any limit for the length of the password. To work around the limitation on systems 

