O que você está pedindo só pode ser feito de duas maneiras
USUÁRIOS PROXY
O MySQL 5.5 introduziu usuários de proxy
When authentication to the MySQL server occurs by means of an authentication plugin, the plugin may request that the connecting (external) user be treated as a different user for privilege-checking purposes. This enables the external user to be a proxy for the second user; that is, to have the privileges of the second user. In other words, the external user is a “proxy user” (a user who can impersonate or become known as another user) and the second user is a “proxied user” (a user whose identity can be taken on by a proxy user).
Você pode encontrar os usuários proxy definidos em mysql.proxies_priv:
mysql> desc mysql.proxies_priv;
+--------------+------------+------+-----+-------------------+-----------------------------+
| Field | Type | Null | Key | Default | Extra |
+--------------+------------+------+-----+-------------------+-----------------------------+
| Host | char(60) | NO | PRI | | |
| User | char(16) | NO | PRI | | |
| Proxied_host | char(60) | NO | PRI | | |
| Proxied_user | char(16) | NO | PRI | | |
| With_grant | tinyint(1) | NO | | 0 | |
| Grantor | char(77) | NO | MUL | | |
| Timestamp | timestamp | NO | | CURRENT_TIMESTAMP | on update CURRENT_TIMESTAMP |
+--------------+------------+------+-----+-------------------+-----------------------------+
7 rows in set (0.22 sec)
mysql>
Aqui está código de exemplo da documentação do MySQL
CREATE USER 'empl_external'@'localhost'
IDENTIFIED WITH auth_plugin AS 'auth_string';
CREATE USER 'employee'@'localhost'
IDENTIFIED BY 'employee_pass';
GRANT PROXY
ON 'employee'@'localhost'
TO 'empl_external'@'localhost';
TIPO DE SEGURANÇA (PROCEDIMENTOS ARMAZENADOS / VISUALIZAÇÕES)
Em mysql.proc
, existe uma coluna chamada security_type
. Com visualizações, isso existe em information_schema.views
. Tem dois valores 1) invoker
e 2) definer
. Se um procedimento armazenado tiver security_type
como definer
, você terá os mesmos direitos de acesso que o proprietário do procedimento armazenado. Claro, isso só é aplicável
- ao chamar um procedimento armazenado ou SELECT de uma exibição
- Você tem o privilégio EXECUTE