Foros del Web » Programación para mayores de 30 ;) » Bases de Datos General » Mysql »

usuarios mysql

Estas en el tema de usuarios mysql en el foro de Mysql en Foros del Web. buenas. Es posible definir un usuario con privilegios a nivel de base de datos y/o a nivel de tabla? Por lo que he visto hasta ...
  #1 (permalink)  
Antiguo 21/06/2008, 19:13
Avatar de moron  
Fecha de Ingreso: mayo-2004
Mensajes: 972
Antigüedad: 19 años, 11 meses
Puntos: 2
usuarios mysql

buenas.
Es posible definir un usuario con privilegios a nivel de base de datos y/o a nivel de tabla?

Por lo que he visto hasta ahora, los usuarios que se generan en mysql son para todas las bases de datos y tablas.
Quisiera dar acceso a determinados usuarios a determinadas tablas de una base de datos pero a otras no.

Usuario externo select a tabla datos publicos
usuario gerencia select a tabla datos protegidos
usuario administrativo insert y select y update a tabla datos publicos y datos protegidos.

muchas gracias desde ya.
  #2 (permalink)  
Antiguo 23/06/2008, 08:04
Colaborador
 
Fecha de Ingreso: marzo-2008
Ubicación: Sabadell
Mensajes: 4.897
Antigüedad: 16 años, 1 mes
Puntos: 574
Respuesta: usuarios mysql

Cada motor tiene sus características pero si se pueden crear usuarios como los que piedes....

Puedes ver esto 13 Lenguaje SQL Usuarios y privilegios o en la ayuda de MySQL

Cita:
Account Management Statements

CREATE USER Syntax
DROP USER Syntax
GRANT Syntax
RENAME USER Syntax
REVOKE Syntax
SET PASSWORD Syntax


MySQL account information is stored in the tables of the mysql database. This database and the access control system are discussed extensively in Database Administration, which you should consult for additional details.

Important: Some releases of MySQL introduce changes to the structure of the grant tables to add new privileges or features. Whenever you update to a new version of MySQL, you should update your grant tables to make sure that they have the current structure so that you can take advantage of any new capabilities. See mysql-upgrade.

MySQL Enterprise. In a production environment it is always prudent to examine any changes to users' accounts. The MySQL Network Monitoring and Advisory Service provides notification whenever users' privileges are altered. For more information see, http://www.mysql.com/products/enterprise/advisors.html.

CREATE USER Syntax

CREATE USER user [IDENTIFIED BY [PASSWORD] 'password']
[, user [IDENTIFIED BY [PASSWORD] 'password']] ...

The CREATE USER statement was added in MySQL 5.0.2. This statement creates new MySQL accounts. To use it, you must have the global CREATE USER privilege or the INSERT privilege for the mysql database. For each account, CREATE USER creates a new record in the mysql.user table that has no privileges. An error occurs if the account already exists. Each account is named using the same format as for the GRANT statement; for example, 'jeffrey'@'localhost'. If you specify only the username part of the account name, a hostname part of '%' is used. For additional information about specifying account names, see GRANT Syntax.

The account can be given a password with the optional IDENTIFIED BY clause. The user value and the password are given the same way as for the GRANT statement. In particular, to specify the password in plain text, omit the PASSWORD keyword. To specify the password as the hashed value as returned by the PASSWORD() function, include the PASSWORD keyword. See GRANT Syntax.

DROP USER Syntax

DROP USER user [, user] ...

te interesa especialmente la GRANT Syntax


Cita:
GRANT Syntax

GRANT priv_type [(column_list)] [, priv_type [(column_list)]] ...
ON [object_type] {tbl_name | * | *.* | db_name.*}
TO user [IDENTIFIED BY [PASSWORD] 'password']
[, user [IDENTIFIED BY [PASSWORD] 'password']] ...
[REQUIRE
NONE |
[{SSL| X509}]
[CIPHER 'cipher' [AND]]
[ISSUER 'issuer' [AND]]
[SUBJECT 'subject']]
[WITH with_option [with_option] ...]

object_type =
TABLE
| FUNCTION
| PROCEDURE

with_option =
GRANT OPTION
| MAX_QUERIES_PER_HOUR count
| MAX_UPDATES_PER_HOUR count
| MAX_CONNECTIONS_PER_HOUR count
| MAX_USER_CONNECTIONS count


The GRANT statement enables system administrators to create MySQL user accounts and to grant rights to from accounts. To use GRANT, you must have the GRANT OPTION privilege, and you must have the privileges that you are granting. The REVOKE statement is related and enables administrators to remove account privileges. See REVOKE Syntax.

MySQL account information is stored in the tables of the mysql database. This database and the access control system are discussed extensively in Database Administration, which you should consult for additional details.

...
Esto tambien te puede servir muestra los privilegios que puede gestionar tu sistema

Cita:
SHOW PRIVILEGES shows the list of system privileges that the MySQL server supports. The exact list of privileges depends on the version of your server.

mysql> SHOW PRIVILEGES\G
*************************** 1. row ***************************
Privilege: Alter
Context: Tables
Comment: To alter the table
*************************** 2. row ***************************
Privilege: Alter routine
Context: Functions,Procedures
Comment: To alter or drop stored functions/procedures
*************************** 3. row ***************************
Privilege: Create
Context: Databases,Tables,Indexes
Comment: To create new databases and tables
*************************** 4. row ***************************
Privilege: Create routine
Context: Functions,Procedures
Comment: To use CREATE FUNCTION/PROCEDURE
*************************** 5. row ***************************
Privilege: Create temporary tables
Context: Databases
Comment: To use CREATE TEMPORARY TABLE
...

Quim

Última edición por quimfv; 23/06/2008 a las 08:28
  #3 (permalink)  
Antiguo 24/06/2008, 10:21
Avatar de moron  
Fecha de Ingreso: mayo-2004
Mensajes: 972
Antigüedad: 19 años, 11 meses
Puntos: 2
Respuesta: usuarios mysql

Exelente. Muchicimas gracias!
  #4 (permalink)  
Antiguo 24/06/2008, 15:33
Avatar de djagu_26  
Fecha de Ingreso: enero-2008
Ubicación: Montevideo, Uruguay
Mensajes: 518
Antigüedad: 16 años, 3 meses
Puntos: 6
Respuesta: usuarios mysql

Eso es a gusto de cada uno lo puede manejar como usuarios del propio motor de base de datos o bien cada base de datos del motor tiene una tabla de usuarios con sus respectivos roles y permisos

saludos
__________________
"La magia no existe, la programacion si"

A/P Agustin Sivoplas
[email protected]
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 22:27.