Databases Reference
In-Depth Information
view running processes. However, the password may be stored in your command-
line history, which other users may be able to access.
database
The database to use. This saves you from having to type USE the_database_name
after the MySQL monitor starts. You can also simply omit the database option and
just add the name of the database you want to use at the end of the mysql command.
safe-updates
Most experienced MySQL users can remember occasions where they've acciden-
tally deleted all the data in a table by issuing a DELETE FROM table_name command,
forgetting to add a limiting condition.
The safe-updates option prevents you from doing this by requiring you to provide
a key constraint to DELETE and UPDATE , or to use a LIMIT clause. For example:
mysql> DELETE FROM user;
ERROR 1175 (HY000): You are using safe update mode and you tried to update
a table without a WHERE that uses a KEY column
We'll explain these commands in later chapters.
Let's look at a couple of examples. First, let's say you want to connect to the server
running on the same machine you're working on ( localhost ), as the MySQL user
root , and with the password the_mysql_root_password . You want to use the database
music , so you would type:
$ mysql --user=root --password= the_mysql_root_password --database=music
Now for a more complex example: say you're working on the host sadri.learning-
mysql.com , and wish to use the Moodle database on the MySQL server listening to port
57777 on the host zahra.learningmysql.com . For this MySQL server, you have the
MySQL account name moodleuser and the password moodlepass . You would type the
command (all on one line):
$ mysql \
--host=zahra.learningmysql.com \
--port=57777 \
--user=moodleuser \
--password=moodlepass \
--database=Moodle
We'll look at how to create and manage users in Chapter 9.
Instead of specifying options on the command line, you can list them in the mysql
section of an options file. You can also store your password in an options file to avoid
typing it in every time you start the monitor. We discuss how to do this in Chapter 11.
Graphical Clients
Before we end this chapter, let's have a quick look at two graphical clients that you can
use in place of the monitor.
 
Search WWH ::




Custom Search