view running processes. However, the password maybe stored
in your command- line history, which other users maybe able to access.
database
The database to use. This saves you from having to type USE
the_database_nameafter 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 accidentally deleted all the data in a table
by issuing a DELETE FROM table_namecommand,
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=musicNow fora 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 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 \ --user=moodleuser \Share with your friends: