To access MySQL from the command line:
mysql --user=username --password=pwd --host=hostname test_db
This can be shortened to:
mysql -u username -p password -h hostname test_db
By omitting the password
value MySQL will ask for any required password as the first input. If you specify password
the client will give you an 'insecure' warning:
mysql -u=username -p -h=hostname test_db
For local connections --socket
can be used to point to the socket file:
mysql --user=username --password=pwd --host=localhost --socket=/path/to/mysqld.sock test_db
Omitting the socket
parameter will cause the client to attempt to attach to a server on the local machine. The server must be running to connect to it.