錯(cuò)誤提示:
We trust you have received the usual lecture from the local System
Administrator. It usually boils down to these three things:
#1) Respect the privacy of others.
#2) Think before you type.
#3) With great power comes great responsibility.
根本原因是mysql用戶去執(zhí)行腳本中的sudo命令時(shí)權(quán)限不夠疑苔,所以我們需要為其配置sudo權(quán)限并加上免密配置。
① 使用su命令切換超級(jí)用戶(root用戶)
② 我們需要在sudoers配置文件中修改,所以先為該文件配置寫權(quán)限:
chmod u+w?/etc/sudoers????????// 給/etc下的sudoers文件加上write權(quán)限
③ 進(jìn)入sudoers文件嘶朱,加上對(duì)應(yīng)用戶的配置語句:
vi /etc/sudoers????????//進(jìn)入文件后找到## Allows people in group wheel to run all commands
④ 配置用戶sudo免密權(quán)限年柠。按i進(jìn)入insert模式,在root ALL=(ALL) ALL下方加上:
[你需要配置的用戶名] ALL = (ALL) ALL? ? ? ? //在sudo的時(shí)候需要輸入密碼
或?
[你需要配置的用戶名] ALL = (ALL) NOPASSWD:ALL? ? ? ? //在sudo的時(shí)候不需輸入密碼
然后esc退出insert模式员寇,按冒號(hào)后輸入wq保存退出凡壤。
⑤ 為了安全考慮移除sudoers文件的寫權(quán)限:
chmod u-w /etc/sudoers? ? ? ? //移除sudoers的寫權(quán)限