shell>
mysql -h host -u user -p
Enter password:
and
host
user
your MySQL account. Substitute appropriate values for your setup. The
password; enter it when
If that works, you should see some introductory information followed by a
shell>
mysql -h host -u user -p
Enter password:
Welcome to the MySQL monitor.
Your MySQL connection id is 25338 to server version: 5.0.96-standard
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
mysql>
The
mysql>
If you are logging in on the same machine that MySQL is running on, you can omit the host, and simply
use the following:
shell>
mysql -u user -p
If, when you attempt to log in, you get an error message such as
connect to local MySQL server through socket '/tmp/mysql.sock'
that the MySQL server daemon (Unix) or service (Windows) is not running. Consult the administrator
or see the section of
system.
For help with other problems often encountered when trying to log in, see
Errors When Using MySQL
Some MySQL installations permit 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
shell>
mysql
After you have connected successfully, you can disconnect any time by typing
prompt:
mysql>
mysql>
QUIT
Bye
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
mysql>
3.2. Entering Queries
Make sure that you are connected to the server, as discussed in the previous section. Doing so does
not in itself select any database to work with, but that is okay. At this point, it is more important to find
out a little about how to issue queries than to jump right in creating tables, loading data into them, and
retrieving data from them. This section describes the basic principles of entering commands, using
several queries you can try out to familiarize yourself with how
Here is a simple command that asks the server to tell you its version number and the current date.
Type it in as shown here following the
mysql>
SELECT VERSION(), CURRENT_DATE;
********
represent the host name where your MySQL server is running and the user name of
displays the
mysql
********
Commands end with ; or \g.
prompt tells you that
mysql
Chapter 2, Installing and Upgrading MySQL
Programs".
without any options:
mysql
prompt.
Entering Queries
Enter password:
is ready for you to enter commands.
prompt and press Enter:
mysql>
194
represents your
********
prompt.
prompt:
mysql>
ERROR 2002 (HY000): Can't
that is appropriate to your operating
Section C.5.2, "Common
(or \q) at the
QUIT
works.
mysql
(2), it means
Need help?
Do you have a question about the 5.0 and is the answer not in the manual?
Questions and answers