Connecting to MySQL Server

To establish a connection to a MySQL server you can use the command line mysql client program.

Connecting without passwing options

$ mysql

Because the are no parameter options, the default values apply :

  • The default hostname is localhost. On Unix use a socket connection

  • The default user is ODBC on Windows

  • The default user is the login name on Unix

  • No password is sent if neither -p nor --password is given

Specify hostname and username

$ mysql --host=localhost --user=root --password=mypassword database

For password options, the password is optional:

If you specifiy a -p or --password option and specify a password value, there must be no space between -p or --password.

If you use -p or --password option but do not specify the password value, the client program prompts to enter the passowrd. This is the recommend option. The password is not displayed as you ente it.

Not specifiying the password option

$ mysql --host=localhost --user=root --password database

is equivalent to

$ mysql -h localhost -u root -p database

Connect with TCP\/IP on Unix

By default on Unix, mysql connects using the socket by default. To use TCP\/IP specify the host or ip address or specifiy the protocol

Specify the hostname

$ mysql -h localhost -u root -p database

or specify the protocol

$ mysql --protocol tcp -u root -p database

Process lsit when logged in using Unix Socket

Process List when logged in with TCP\/IP option

results matching ""

    No results matching ""