Oracle 5.0 Reference Manual page 619

Table of Contents

Advertisement

To set up a superuser account, it is necessary only to insert a
set to 'Y'. The
table privileges are global, so no entries in any of the other grant tables are
user
needed.
The next examples create three accounts and give them access to specific databases. Each of them
has a user name of
custom
To create the accounts with
shell>
mysql --user=root mysql
mysql>
CREATE USER 'custom'@'localhost' IDENTIFIED BY 'obscure';
mysql>
GRANT SELECT,INSERT,UPDATE,DELETE,CREATE,DROP
->
ON bankaccount.*
->
TO 'custom'@'localhost';
mysql>
CREATE USER 'custom'@'host47.example.com' IDENTIFIED BY 'obscure';
mysql>
GRANT SELECT,INSERT,UPDATE,DELETE,CREATE,DROP
->
ON expenses.*
->
TO 'custom'@'host47.example.com';
mysql>
CREATE USER 'custom'@'server.domain' IDENTIFIED BY 'obscure';
mysql>
GRANT SELECT,INSERT,UPDATE,DELETE,CREATE,DROP
->
ON customer.*
->
TO 'custom'@'server.domain';
The three accounts can be used as follows:
• The first account can access the
• The second account can access the
host47.example.com.
• The third account can access the
To set up the
accounts without GRANT, use
custom
tables directly:
shell>
mysql --user=root mysql
mysql>
INSERT INTO user (Host,User,Password)
->
VALUES('localhost','custom',PASSWORD('obscure'));
mysql>
INSERT INTO user (Host,User,Password)
->
VALUES('host47.example.com','custom',PASSWORD('obscure'));
mysql>
INSERT INTO user (Host,User,Password)
->
VALUES('server.domain','custom',PASSWORD('obscure'));
mysql>
INSERT INTO db
->
(Host,Db,User,Select_priv,Insert_priv,
->
Update_priv,Delete_priv,Create_priv,Drop_priv)
->
VALUES('localhost','bankaccount','custom',
->
'Y','Y','Y','Y','Y','Y');
mysql>
INSERT INTO db
->
(Host,Db,User,Select_priv,Insert_priv,
->
Update_priv,Delete_priv,Create_priv,Drop_priv)
->
VALUES('host47.example.com','expenses','custom',
->
'Y','Y','Y','Y','Y','Y');
mysql>
INSERT INTO db
->
(Host,Db,User,Select_priv,Insert_priv,
->
Update_priv,Delete_priv,Create_priv,Drop_priv)
->
VALUES('server.domain','customer','custom',
->
'Y','Y','Y','Y','Y','Y');
mysql>
FLUSH PRIVILEGES;
The first three
INSERT
the various hosts with the given password, but grant no global privileges (all privileges are set to the
default value of 'N'). The next three
for the bankaccount, expenses, and
custom
the proper hosts. As usual when you modify the grant tables directly, you must tell the server to reload
them with
FLUSH PRIVILEGES
To create a user who has access from all machines in a given domain (for example, mydomain.com),
you can use the "%" wildcard character in the host part of the account name:
Adding User Accounts
and password of obscure.
and GRANT, use the following statements:
CREATE USER
bankaccount
expenses
customer
statements add
table entries that permit the user
user
statements add
INSERT
so that the privilege changes take effect.
599
table row with all privilege columns
user
database, but only from the local host.
database, but only from the host
database, but only from the host server.domain.
statements as follows to modify the grant
INSERT
table entries that grant privileges to
db
databases, but only when accessed from
customer
to connect from
custom

Advertisement

Table of Contents
loading

This manual is also suitable for:

Mysql 5.0

Table of Contents