Oracle 5.0 Reference Manual page 635

Table of Contents

Advertisement

wildcards, whereas account values (as returned by
and host name wildcards.
For example, a blank user name matches any user, so an account of
clients to connect as an anonymous user from the local host with any user name. If this case, if a client
connects as
from the local host,
user1
values:
mysql>
SELECT USER(), CURRENT_USER();
+-----------------+----------------+
| USER()
| CURRENT_USER() |
+-----------------+----------------+
| user1@localhost | @localhost
+-----------------+----------------+
The host name part of an account can contain wildcards, too. If the host name contains a
pattern character or uses netmask notation, the account can be used for clients connecting from
'_'
multiple hosts and the
CURRENT_USER()
the account
'user2'@'%.example.com'
the
domain. If
example.com
[959]
CURRENT_USER()
mysql>
SELECT USER(), CURRENT_USER();
+--------------------------+---------------------+
| USER()
+--------------------------+---------------------+
| user2@remote.example.com | user2@%.example.com |
+--------------------------+---------------------+
If an application must invoke
within triggers) but must also be able to associate the
table, it is necessary to avoid accounts that contain wildcards in the
user
Specifically, do not permit
permit pattern characters or netmask notation in
value and literal
User
Host
With respect to the previous examples, the
accounts should be changed not to use wildcards:
RENAME USER ''@'localhost' TO 'user1'@'localhost';
RENAME USER 'user2'@'%.example.com' TO 'user2'@'remote.example.com';
If
must be able to connect from several hosts in the
user2
separate account for each host.
To extract the user name or host name part from a
use the
SUBSTRING()
mysql>
SELECT SUBSTRING_INDEX(CURRENT_USER(),'@',1);
+---------------------------------------+
| SUBSTRING_INDEX(CURRENT_USER(),'@',1) |
+---------------------------------------+
| user1
+---------------------------------------+
mysql>
SELECT SUBSTRING_INDEX(CURRENT_USER(),'@',-1);
+----------------------------------------+
| SUBSTRING_INDEX(CURRENT_USER(),'@',-1) |
+----------------------------------------+
| localhost
+----------------------------------------+
SQL-Based MySQL Account Activity Auditing
USER()
|
[959]
can be used by
connects from remote.example.com,
user2
return different values:
| CURRENT_USER()
[964]
for user auditing (for example, if it does auditing from
USER()
to be empty (which creates an anonymous-user account), and do not
User
value.
''@'localhost'
[894]
function:
|
|
615
CURRENT_USER()
''@'localhost'
[964]
and
CURRENT_USER()
value will not indicate which one. For example,
to connect from any host in
user2
|
[964]
value with an account in the
USER()
values. All accounts must have a nonempty
Host
and
'user2'@'%.example.com'
example.com
[959]
CURRENT_USER()
[959]) may contain user name
enables
[959]
return different
'%'
[964]
and
USER()
or
column.
User
Host
domain, there should be a
or
[964]
value,
USER()
or

Advertisement

Table of Contents
loading

This manual is also suitable for:

Mysql 5.0

Table of Contents