Archivo de la Categoría “Mysql”

Dar permisos al usuario sergio en bdsainz desde la ip 1.1.1.1 y con contraseña qwerty

mysql> GRANT ALL ON bdsainz.* TO sergio@'1.1.1.1' IDENTIFIED BY 'qwerty';

mysql> REVOKE GRANT OPTION ON bdsainz.* FROM sergio@'1.1.1.1';

Ver permisos de un usuario:

SHOW GRANTS FOR "sergio"@"1.1.1.1" ;

Para ver todos los permisos hay que usar un procedimiento almacenado:

  1. USE mysql;
  2. DELIMITER //
  3. CREATE PROCEDURE showAllGrants() BEGIN
  4. DECLARE done INT DEFAULT 0;
  5. DECLARE theUser CHAR(16);
  6. DECLARE theHost CHAR(16);
  7. DECLARE cur1 CURSOR FOR SELECT user, host FROM mysql.user;
  8. DECLARE CONTINUE HANDLER FOR SQLSTATE '02000' SET done = 1;
  9. OPEN cur1;
  10. REPEAT
  11. FETCH cur1 INTO theUser, theHost;
  12. IF NOT done THEN
  13. SET @sql := CONCAT('SHOW GRANTS FOR \'', theUser, '\'@\'', theHost, '\'');
  14. PREPARE grantStatement FROM @sql;
  15. EXECUTE grantStatement;
  16. DROP PREPARE grantStatement;
  17. END IF;
  18. UNTIL done END REPEAT;
  19. CLOSE cur1;
  20. END//
  21. DELIMITER ;
  22. CALL showAllGrants();

Pegado de <http://forge.mysql.com/snippets/view.php?id=95>

No permitir accesos remotos:

Editar /etc/my.cnf e incluir/descomentar la línea skip-networking dentro de [mysqld] y reiniciar mysql.

Comments No Hay Comentarios »

Este tipo de error se produce cuando se intenta almacenar archivos más grandes de lo que MySql tiene configurado (por defecto 1 Mb)

Got a packet bigger than ‘max_allowed_packet’ bytes

Puedes ver lo que hay actualmente establecido accediendo a mysql y ejecutando:

mysql> show variables like 'max%' ;

+-----------------------+------------+

| Variable_name         | Value      |

+-----------------------+------------+

| max_allowed_packet    | 1048576    |
			

Una forma de modificarlo es desde aquí haciendo:

mysql> set max_allowed_packet = 2000000;

Query OK, 0 rows affected (0.03 sec)

De esta manera en principio no sería necesario reiniciar mysql, en cambio si es recomendable hacerlo.

También se puede ir al archivo de configuración de mysql:

  • En LINUX:
    /etc/my.cnf
  • En Windows:
    c:\Windows\my.ini

Y dentro de la sección [mysqld] agregar (o editar) la siguiente línea:

max_allowed_packet = 20M

Por último será necesario reiniciar el servicio de mysql.

Comments 1 Comentario »