Skip to main content
5 de 5
se añadieron 173 caracteres en el cuerpo
user avatar
user avatar

Se me ocurre que saques los permisos de la tabla mysql.user de este modo

SELECT user, Select_priv, Insert_priv, Update_priv, Delete_priv
FROM mysql.user
WHERE User = "tuUsuario";

Dándote un resultado similar al siguiente

+-----------+-------------+-------------+-------------+-------------+
| user      | Select_priv | Insert_priv | Update_priv | Delete_priv |
+-----------+-------------+-------------+-------------+-------------+
| tuUsuario | Y           | Y           | Y           | Y           |
+-----------+-------------+-------------+-------------+-------------+
1 row in set (0.001 sec)

Los permisos se guardan en un campo de tipo ENUM con valores por defecto como YES o NO dependiendo si tiene esos permisos asignados

Yo solo coloque algunos datos de referencia, pero si haces un

DESCRIBE mysql.user;

Veras un resultado similar al siguiente, de donde tu puedes elegir que otros valores deseas conocer para la cuenta de un usuario en específico

MySQL [(none)]> DESCRIBE mysql.user;
+--------------------------+-----------------------------------+------+-----+---------------
--------+-------+
| Field                    | Type                              | Null | Key | Default
        | Extra |
+--------------------------+-----------------------------------+------+-----+---------------
--------+-------+
| Host                     | char(60)                          | NO   | PRI |
        |       |
| User                     | char(32)                          | NO   | PRI |
        |       |
| Select_priv              | enum('N','Y')                     | NO   |     | N
        |       |
| Insert_priv              | enum('N','Y')                     | NO   |     | N
        |       |
| Update_priv              | enum('N','Y')                     | NO   |     | N
        |       |
| Delete_priv              | enum('N','Y')                     | NO   |     | N
        |       |
| Create_priv              | enum('N','Y')                     | NO   |     | N
        |       |
| Drop_priv                | enum('N','Y')                     | NO   |     | N
        |       |
| Reload_priv              | enum('N','Y')                     | NO   |     | N
        |       |
| Shutdown_priv            | enum('N','Y')                     | NO   |     | N
        |       |
| Process_priv             | enum('N','Y')                     | NO   |     | N
        |       |
| File_priv                | enum('N','Y')                     | NO   |     | N
        |       |
| Grant_priv               | enum('N','Y')                     | NO   |     | N
        |       |
| References_priv          | enum('N','Y')                     | NO   |     | N
        |       |
| Index_priv               | enum('N','Y')                     | NO   |     | N
        |       |
| Alter_priv               | enum('N','Y')                     | NO   |     | N
        |       |
| Show_db_priv             | enum('N','Y')                     | NO   |     | N
        |       |
| Super_priv               | enum('N','Y')                     | NO   |     | N
        |       |
| Create_tmp_table_priv    | enum('N','Y')                     | NO   |     | N
        |       |
| Lock_tables_priv         | enum('N','Y')                     | NO   |     | N
        |       |
| Execute_priv             | enum('N','Y')                     | NO   |     | N
        |       |
| Repl_slave_priv          | enum('N','Y')                     | NO   |     | N
        |       |
| Repl_client_priv         | enum('N','Y')                     | NO   |     | N
        |       |
| Create_view_priv         | enum('N','Y')                     | NO   |     | N
        |       |
| Show_view_priv           | enum('N','Y')                     | NO   |     | N
        |       |
| Create_routine_priv      | enum('N','Y')                     | NO   |     | N
        |       |
| Alter_routine_priv       | enum('N','Y')                     | NO   |     | N
        |       |
| Create_user_priv         | enum('N','Y')                     | NO   |     | N
        |       |
| Event_priv               | enum('N','Y')                     | NO   |     | N
        |       |
| Trigger_priv             | enum('N','Y')                     | NO   |     | N
        |       |
| Create_tablespace_priv   | enum('N','Y')                     | NO   |     | N
        |       |
| ssl_type                 | enum('','ANY','X509','SPECIFIED') | NO   |     |
        |       |
| ssl_cipher               | blob                              | NO   |     | NULL
        |       |
| x509_issuer              | blob                              | NO   |     | NULL
        |       |
| x509_subject             | blob                              | NO   |     | NULL
        |       |
| max_questions            | int(11) unsigned                  | NO   |     | 0
        |       |
| max_updates              | int(11) unsigned                  | NO   |     | 0
        |       |
| max_connections          | int(11) unsigned                  | NO   |     | 0
        |       |
| max_user_connections     | int(11) unsigned                  | NO   |     | 0
        |       |
| plugin                   | char(64)                          | NO   |     | caching_sha2_p
assword |       |
| authentication_string    | text                              | YES  |     | NULL
        |       |
| password_expired         | enum('N','Y')                     | NO   |     | N
        |       |
| password_last_changed    | timestamp                         | YES  |     | NULL
        |       |
| password_lifetime        | smallint(5) unsigned              | YES  |     | NULL
        |       |
| account_locked           | enum('N','Y')                     | NO   |     | N
        |       |
| Create_role_priv         | enum('N','Y')                     | NO   |     | N
        |       |
| Drop_role_priv           | enum('N','Y')                     | NO   |     | N
        |       |
| Password_reuse_history   | smallint(5) unsigned              | YES  |     | NULL
        |       |
| Password_reuse_time      | smallint(5) unsigned              | YES  |     | NULL
        |       |
| Password_require_current | enum('N','Y')                     | YES  |     | NULL
        |       |
| User_attributes          | json                              | YES  |     | NULL
        |       |
+--------------------------+-----------------------------------+------+-----+---------------
--------+-------+
51 rows in set (0.006 sec)

Y te vas a concentrar para lo que buscas en las columnas

  • Select_priv
  • Insert_priv
  • Delete_priv
  • Update_priv

No olvides al final agregar el

WHERE User = "tuUsuario" 

Para que te muestre que tipo de privilegios tiene tu usuario en específico

Aquí te dejo la dcoumentación oficial para que consultes mas sobre lo que contiene la tabla antes mencionada

user75901