To connect to the server, you will usually need to provide a MySQL user name when you invokeÂ mysqlÂ and, most likely, a password. If the server runs on a machine other than the one where you log in, you will also need to specify a host name. Contact your administrator to find out what connection parameters you should use to connect (that is, what host, user name, and password to use). Once you know the proper parameters, you should be able to connect like this:
mysql -hEnter password:
userÂ represent the host name where your MySQL server is running and the user name of your MySQL account. Substitute appropriate values for your setup. TheÂ
********represents your password; enter it whenÂ mysqlÂ displays theÂ
Enter password:Â prompt.
If that works, you should see some introductory information followed by aÂ
mysql -hEnter password:
********Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 25338 to server version: 5.0.72-standard Type 'help;' or '\h' for help. Type '\c' to clear the buffer. mysql>
mysql>Â prompt tells you thatÂ mysqlÂ is ready for you to enter commands.
If you are logging in on the same machine that MySQL is running on, you can omit the host, and simply use the following:
If, when you attempt to log in, you get an error message such asÂ ERROR 2002 (HY000): Can’t connect to local MySQL server through socket ‘/tmp/mysql.sock’ (2), it means that that MySQL server daemon (Unix) or service (Windows) is not running. Consult the administrator or see the section ofÂ ChapterÂ 2,Â Installing and Upgrading MySQLÂ that is appropriate to your operating system.
For help with other problems often encountered when trying to log in, seeÂ SectionÂ B.1.2, â€œCommon Errors When Using MySQL Programsâ€.
Some MySQL installations allow users to connect as the anonymous (unnamed) user to the server running on the local host. If this is the case on your machine, you should be able to connect to that server by invokingÂ mysqlwithout any options:
After you have connected successfully, you can disconnect any time by typingÂ
\q) at theÂ
On Unix, you can also disconnect by pressing Control-D.
Most examples in the following sections assume that you are connected to the server. They indicate this by the
This Article has been taken fromÂ http://dev.mysql.com/doc/refman/5.0