content_image/732431.jpg content_image/732430.jpg
| keyring_key_generate(’SharedKey’, ’DSA’, 8) | +---------------------------------------------+ | 1 | +---------------------------------------------+ 

From the administrative account, create an ordinary user account to which key access is to be granted: 

mysql> CREATE USER ’key_user’@’localhost’ IDENTIFIED BY ’key_user_pwd’; 

From the key_user  account, verify that, without the proper EXECUTE  privilege, the new account cannot access the shared key: 

mysql> SELECT HEX(key_schema.get_shared_key()); ERROR 1370 (42000): execute command denied to user ’key_user’@’localhost’ for routine ’key_schema.get_shared_key’ 

From the administrative account, grant EXECUTE  to key_user  for the stored function: 

## General-Purpose Keyring Function Reference 

mysql> GRANT EXECUTE ON FUNCTION key_schema.get_shared_key TO ’key_user’@’localhost’; 

From the key_user  account, verify that the key is now accessible: 

mysql> SELECT HEX(key_schema.get_shared_key()); +----------------------------------+ | HEX(key_schema.get_shared_key()) | +----------------------------------+ | 9BAFB9E75CEEB013 | +----------------------------------+ 

For each general-purpose keyring function, this section describes its purpose, calling sequence, and return value. For information about the conditions under which these functions can be invoked, see Using General-Purpose Keyring Functions. 

• keyring_key_fetch( key_id ) 

Given a key ID, deobfuscates and returns the key value. 

Arguments: 

• key_id : A string that specifies the key ID. 

Return value: 

Returns the key value as a string for success, NULL  if the key does not exist, or NULL  and an error for failure. 

<img src='content_image/732431.jpg'>

Example: 

<img src='content_image/732430.jpg'>

## Note 

Key values retrieved using keyring_key_fetch()  are subject to the general keyring function limits described in Section 6.4.4.12, “Supported Keyring Key Types and Lengths” . A key value longer than that length can be stored using a keyring service function (see Section 5.6.9.2, “The Keyring Service” ), but if retrieved using keyring_key_fetch()  is truncated to the general keyring function limit. 

