This article describes how to use the command line to connect to and disconnect a database. To connect to the server, a mysql User name and password are usually required when MySQL is called. To connect to the server
MysqlA MySQL User name and a password are usually required. If the server runs on a machine other than the login server, you must specify the host name. Contact the administrator to find the connection parameters (that is, the connected host, user name, and password ). After you know the correct parameters, you can connect them as follows:
shell> mysql -h host -u user -pEnter password: ********
Host and user respectively represent the host name and MySQL account user name running on the MySQL server. Replace the value with the correct one. * ******* Indicates your password.MysqlShow Enter password: Enter it when prompted.
If valid, you should see some introduction information after the mysql> prompt:
shell> mysql -h host -u user -pEnter password: ********Welcome to the MySQL monitor. Commands end with ; or \g.Your MySQL connection id is 25338 to server version: 5.1.2-alpha-standardType 'help;' or '\h' for help. Type '\c' to clear the buffer.mysql>
Mysql> the prompt tells you that mysql is ready to enter the command for you.
SomeMySQLThe installation allows anonymous (Untitled) users to connect to the server running on the local host. If your machine is in this situation, you should be able to call it without any options.MysqlConnect to the server:
shell> mysql
After successful connection, you can enter QUIT (or \ q) at the mysql> prompt to exit at any time:
mysql> QUIT
In Unix, you can also press control-D to disconnect the server.