To connect to MySQL Server, we should know mysqladmin username and password.
The following syntax is used to connect through command prompt.
shell>mysql -h host -u username -p Enter password:******
host represents the host name where mysql is running and and username represents username.
A welcome message will be display after successful connection.
You can omit hostname if you are working on the same machine where mysql is installed.Like -
The mysql> prompt indicates to enter your next command.
shell>mysql -u username -p Enter password:******
If you are using mysql for PHP, then PHP provides mysql_connect method to connect to mysql.
mysql_connect(host, username, password);
MySQL Disconnect Connection
QUIT commend is used to disconnect from the current connection.