Database Reference
In-Depth Information
The mysql Client
With the
mysql
client, you may interact with the MySQL or MariaDB server from either
the command line or within an interface environment called the
monitor
. The command-
line method of using
mysql
allows you to interact with the server without much overhead. It
also allows you to enter MySQL commands in scripts and other programs. For instance,
you can put lines in
cron
to perform maintenance tasks and make backups automatically of
databases. The monitor is an ASCII display of
mysql
that makes the text a little more or-
ganized and provides more information about commands you execute. Almost all of the ex-
amples in this topic are taken from the monitor display. If they're not, I will note that they
are from the command line.
If MySQL or MariaDB was installed properly on your server,
mysql
should be available for
you to use. If not, see
Post-Installation
to make sure everything is configured correctly on
your system and make sure you created the necessary symbolic links or aliases. The
mysql
client should be in the
/bin/
or
/usr/bin/
directory. Windows, Macs, and other operating sys-
tems with GUIs have file location utilities for finding a program. Look for the directory
containing the
mysql
client and the other binary files for MySQL.
Assuming that everything is working, you will need a MySQL username and password to
be able to connect to MySQL, even with the
mysql
client. If you're not the administrator,
you must obtain these credentials from the appointed person. If MySQL or MariaDB was
just installed and the
root
password is not set yet, its password is blank — that is to say,
just press the Enter key when prompted for the password. To learn how to set the
root
pass-
word and to create new users and grant them privileges, see
Post-Installation
for starting
pointers and
Chapter13
for more advanceddetails.