3.1. The mysql Client


There are various methods for interacting with the MySQL server and, thereby, developing or working with a database. The most basic interface that you can use, though, is the mysql client. With it, you may interact with the server from either the command line or what is sometimes called the monitor.

If MySQL was installed properly on your server, mysql should be available to run. If not see Chapter 2. If you used the default installation method, the mysql program resides at /usr/local/mysql/bin/mysql. On Unix systems, be sure that mysql is in your path by typing:

PATH=$PATH:/usr/local/mysql/bin export PATH

Assuming that everything is working, you will also need a MySQL username and an accompanying password. If you're not the administrator, you must obtain these from her. If MySQL was just installed and the root password is not set yet, its password is blank. See Chapter 2 to learn how to set passwords, and to create new users and grant them privileges.

From a shell prompt, log in to MySQL like so:

mysql -h host -u user -p

If you're logging in locally that is to say, from the server itself either physically or through a remote login method, such as Telnet or the SSH secure shell, you can omit the -h host argument. This is because the default host is localhost, which refers to the system you are on. In other circumstances, where your commands actually have to travel over a network to reach the server, replace the argument host with either a hostname that is translatable to an IP address or the actual IP address of the MySQL server.

You should replace the argument user with your username. The -p option instructs mysql to prompt you for a password. You can also add the password to the end of the -p option (e.g., enter -prover where rover is the password); there's no space between -p and the password. However, entering the password on the command line is not a good security practice, because it displays the password on the screen and it transmits the password as clear text through the network, as well as making it visible whenever somebody gets a list of processes running on the machine.

To exit mysql, type quit or exit, and press the Enter key.



MySQL in a Nutshell
MYSQL in a Nutshell (In a Nutshell (OReilly))
ISBN: 0596514336
EAN: 2147483647
Year: 2006
Pages: 134
Authors: Russell Dyer

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net