Determine if MySQL has been started with skip tables

Is there a way to find out if MySQL is started using skip-grant-tables in mysql? I cannot find anything inshow variables

I would like to add a protector to the startup sql script to prevent attempts to create UDFs when they cannot be (e.g. dock startup gets started, etc.)

thank

+3


source to share


1 answer


There doesn't seem to be a variable to determine this.

The following stored procedure might give you some ideas:



DELIMITER //

DROP PROCEDURE IF EXISTS `_`.`skip_grant_tables`//

CREATE PROCEDURE `_`.`skip_grant_tables`(OUT `skip_grant` BOOL)
BEGIN
  DECLARE `skip_grant_text` TEXT;
  DECLARE CONTINUE HANDLER FOR SQLEXCEPTION
  BEGIN
    GET DIAGNOSTICS CONDITION 1 `skip_grant_text` = MESSAGE_TEXT;
  END;
  SET `skip_grant` := 0;
  GRANT SELECT ON *.* TO ''@'';
  IF (`skip_grant_text` REGEXP '--skip-grant-tables option') THEN
    SET `skip_grant` := 1;
  END IF;
END//

DELIMITER ;

mysql> CALL `_`.`skip_grant_tables`(@`skip_grant_tables?`);
Query OK, 0 rows affected (0.00 sec)

mysql> SELECT @`skip_grant_tables?`;
+-----------------------+
| @`skip_grant_tables?` |
+-----------------------+
|                     1 |
+-----------------------+
1 row in set (0.00 sec)

      

+2


source







All Articles