Microsoft Word - Sam's Teach Yourself MySQL in 21 Days - SAMS.doc

(singke) #1
ƒ HOSTS Clears the hosts cache tables. Use this option if one of your hosts IP
addresses change or if the local IP address changes.
ƒ LOGS Closes all open logs.
ƒ PRIVILEGES Use this when you add a new user or change information in the
MySQL database. Reloads the grant tables.
ƒ TABLES Closes all open tables.
ƒ STATUS Resets system status variable to 0.

Example:
FLUSH PRIVILEGES

More than one option can be stated at a time.
FLUSH PRIVILEGES, TABLES

GRANT


privilege ON database_object TO user_name IDENTIFIED BY password [WITH GRANT
OPTION]


This command grants user privileges. This is the preferred method of adding users. The administrator
may grant one, some, or all of the following privileges:
ALL PRIVILEGES ALTER CREATE
DELETE DROP FILE
INDEX INSERT PROCESS
REFERENCES RELOAD SELECT
SHUTDOWN UPDATE USAGE

The database object can be a column, table, or database.
The password is encrypted automatically. Do not use the password() function.
Remember to reload your grant tables after making changes using the FLUSH command.
Using the WITH GRANT OPTION option gives the user the ability to grant options to other users.

Wildcard characters can be used when specifying a host.
The IDENTIFIED BY clause is optional, but, to ensure the security of your database, it is highly
recommended.

Example:

To grant a user all privileges to all databases and also give them the ability to grant privileges to others,
use the following:
GRANT ALL PRIVILEGES ON *.*
TO mark@localhost IDENTIFIED
BY "dinosaur"
WITH GRANT OPTION
To grant a user SELECT and UPDATE privileges to a specific database, use the following:
GRANT SELECT, UPDATE ON Meet_A_Geek.*
TO sydney@localhost
IDENTIFIED BY "toys"

To create a user with no privileges, use the following:
GRANT USAGE ON *.* TO user@localhost

INSERT


[LOW_PRIORITY or DELAYED] [IGNORE] [INTO] table_name [(column_list)]
VALUES(value_list), INSERT [LOW_PRIORITY or DELAYED] [IGNORE] [INTO] table_name
[(column_list)] SELECT ..., INSERT [LOW_PRIORITY or DELAYED] [IGNORE] [INTO]
table_name [(column_list)] SET column_name = expression[, column_name =
expression] ...
These statements add new rows to an existing table. If no column names are used, the values in the
VALUES list must match up to the table's columns by type, position, and number. If the column names

Free download pdf