O'Reilly logo

MySQL in a Nutshell by Russell J.T. Dyer

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required