mysql 1370,[Err] 1370 - execute command denied to user

問題描述:

Mysql中UserA 調用UserB的函數時遇到

[Err] 1370 - execute command denied to user ‘test’@’127.0.0.1’ for routine ‘lw.historynextval’

查看UserA的權限

mysql> show grants for UserA@192.168.10.61;

GRANT EXECUTE ON FUNCTION lw.historynextval TO ‘UserA’@’192.168.10.61’

UserA調用UserB的函數,返回[Err] 1370,Why?

mysql -uUserA -p -h 127.0.0.1 -P 3316 -e “select lw.historynextval()”

[Err] 1370 - execute command denied to user ‘test’@’127.0.0.1’ for routine ‘lw.historynextval’

用UserB調用自己定義的函數,返回ERROR 1370 (42000)

mysql -uUserB -p -h 127.0.0.1 -P 3316 -e “select lw.historynextval()”

Enter password:

ERROR 1370 (42000) at line 1: execute command denied to user ‘test’@’127.0.0.1’ for routine ‘lw.historynextval’

從錯誤的描述來看是,UserB沒有執行自己定義函數的權限

授權給UserB執行函數的權限

GRANT EXECUTE ON lw.* TO ‘test’@’127.0.0.1’;

用UserB調用自己定義的函數,成功。

mysql -utest -p -h 127.0.0.1 -P 3316 -e “select lw.historynextval()”

Enter password:

+———————+

| lw.historynextval() |

+———————+

| 21 |

+———————+

UserA調用UserB的函數,成功。

mysql -uUserA -p -h 127.0.0.1 -P 3316 -e “select lw.historynextval()”

+———————+

| lw.historynextval() |

+———————+

| 22 |

+———————+

Mysql中調用其它用戶定義的函數時:

1.首先要確保函數的定義者有執行自己定義函數的權限。

如:用戶A,創建了函數fun1。首先要保證用戶A能調用函數fun1.

2.函數的調用者要有調用函數的權限

用戶B要調用A用戶定義的函數fun1,要確保用戶B被授權調用A用戶的函數

3.如果函數中涉及到對相關表的權限,也要授予函數的調用者。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值