Tenho um usuário que pode ser acessado de qualquer host (estamos atualmente em desenvolvimento). Mas quero limitar a execução de procedimentos armazenados apenas para localhost. O problema é que o localhost
usuário não é reconhecido.
DROP USER IF EXISTS 'admin'@'%';
CREATE USER IF NOT EXISTS 'admin'@'%' IDENTIFIED WITH 'caching_sha2_password' BY 'my_password';
###########################
### STORED PROCEDURES ###
###########################
GRANT EXECUTE ON MY_DATABASE.* TO 'admin'@'127.0.0.1';
###########################
### SELECT ###
###########################
GRANT SELECT ON MY_DATABASE.MY_TABLE TO 'admin'@'%' WITH GRANT OPTION;
GRANT SELECT ON MY_DATABASE.MY_TABLE2 TO 'admin'@'%' WITH GRANT OPTION;
.
.
.
Executar esse código me gera o próximo erro.
[2024-11-23 20:59:09] [42000][1410] You are not allowed to create a user with GRANT
Alterar o host "resolve" o erro, mas quero limitar a execução ao localhost. Não sei se preciso apenas adicionar um novo usuário assim.
CREATE USER IF NOT EXISTS 'admin'@'127.0.0.1' IDENTIFIED WITH 'caching_sha2_password' BY 'my_password';
###########################
### STORED PROCEDURES ###
###########################
GRANT EXECUTE ON MY_DATABASE.* TO 'admin'@'127.0.0.1';
###########################
### SELECT ###
###########################
GRANT SELECT ON MY_DATABASE.MY_TABLE1 TO 'admin'@'127.0.0.1' WITH GRANT OPTION;
GRANT SELECT ON MY_DATABASE.MY_TABLE2 TO 'admin'@'127.0.0.1' WITH GRANT OPTION;
.
.
.
Ou se houver outra maneira sem repetir a definição do usuário