Differences
This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
docs:mysql:grant [2007/04/19 12:07] – billh | docs:mysql:grant [2008/08/03 00:25] (current) – external edit 127.0.0.1 | ||
---|---|---|---|
Line 8: | Line 8: | ||
===== Grants ===== | ===== Grants ===== | ||
* http:// | * http:// | ||
- | |||
==== Adding a New User ==== | ==== Adding a New User ==== | ||
Line 19: | Line 18: | ||
IDENTIFIED BY ' | IDENTIFIED BY ' | ||
</ | </ | ||
- | | + | |
+ | |||
+ | ==== Example ==== | ||
+ | After connecting to the server as root, you can add new accounts. The following statements use GRANT to set up four new accounts: | ||
+ | |||
+ | <code mysql> | ||
+ | mysql> GRANT ALL PRIVILEGES ON *.* TO ' | ||
+ | -> | ||
+ | mysql> GRANT ALL PRIVILEGES ON *.* TO ' | ||
+ | -> | ||
+ | mysql> GRANT RELOAD, | ||
+ | mysql> GRANT USAGE ON *.* TO ' | ||
+ | </ | ||
+ | |||
+ | The accounts created by these GRANT statements have the following properties: | ||
+ | |||
+ | * Two of the accounts have a username of monty and a password of some_pass. Both accounts are superuser accounts with full privileges to do anything. One account (' | ||
+ | * One account has a username of admin and no password. This account can be used only by connecting from the local host. It is granted the RELOAD and PROCESS administrative privileges. These privileges allow the admin user to execute the mysqladmin reload, mysqladmin refresh, and mysqladmin flush-xxx commands, as well as mysqladmin processlist . No privileges are granted for accessing any databases. You could add such privileges later by issuing additional GRANT statements. | ||
+ | * One account has a username of dummy and no password. This account can be used only by connecting from the local host. No privileges are granted. The USAGE privilege in the GRANT statement enables you to create an account without giving it any privileges. It has the effect of setting all the global privileges to ' | ||
+ | * The statements that create accounts with no password will fail if the NO_AUTO_CREATE_USER SQL mode is enabled. To deal with this, use an IDENTIFIED BY clause that specifies a non-empty password. | ||
+ | |||
+ | * **SEE ALSO: | ||
==== Removing a User ==== | ==== Removing a User ==== |