Specifications
The mysql command invokes the MySQL monitor. This is a command line client that connects
you to the MySQL server.
The -h switch is used to specify the host to which you want to connect; that is, the machine on
which the MySQL server is running. If you’re running this command on the same machine as
the MySQL server, you can leave out this switch and the hostname parameter. If not, you
should replace the hostname parameter with the name of the machine where the MySQL server
is running.
The -u switch is used to specify the username you want to connect as. If you do not specify,
the default will be the username you are logged into the operating system as.
If you have installed MySQL on your own machine or server, you will need to log in as root
and create the database we’ll use in this section. Assuming that you have a clean install, root
is the only user you’ll have to begin with.
If you are using MySQL on a machine administered by somebody else, use the username they
gave you.
The -p switch tells the server you want to connect using a password. You can leave it out if a
password has not been set for the user you are logging in as.
If you are logging in as root and have not set a password for root, I strongly recommend that
you visit Appendix A and do so right now. Without a root password, your system is insecure.
You don’t need to include the password on this line. The MySQL server will ask you for it. In
fact, it’s better if you don’t. If you enter the password on the command line, it will appear as
plain text on the screen, and will be quite simple for other users to discover.
After you have entered the previous command, you should get a response something like this:
Enter password: ****
(If this hasn’t worked, verify that the MySQL server is running, and the mysql command is
somewhere in your path.)
You should enter your password. If all goes well, you should see a response something like
this:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 9 to server version: 3.22.34-shareware-debug
Type ‘help’ for help.
mysql>
On your own machine: If you don’t get a response similar to this, make sure that you have run
mysql_install_db if required, you have set the root password, and you’ve typed it in cor-
rectly.
Using MySQL
P
ART II
186
11 7842 CH08 3/6/01 3:38 PM Page 186