LInux用戶管理:
// 新建用戶組
groupadd mysql
// 查看用戶組
cat /etc/group | grep mysql
// 添加用戶進用戶組[組+用戶]
usermod -G mysql mysql
// 新建用戶
useradd -ms /bin/bash mysql
|- useradd -m 效果等同於'-d /home/username',自動創建
|- useradd -s /bin/bash
|- useradd -d /home/username
// 查看用戶
cat /etc/passwd | grep mysql
id mysql
// 刪除用戶
// 參數r會刪除該用戶的主目錄,請注意
userdel mysql
userdel -r mysql
-------------------------------
-------------------------------
// root用戶下爲新建的用戶設置密碼:
passwd mysql
...
...
// 修改用戶的默認shell[一般默認爲/bin/sh]
// 該項可以在useradd中直接修改
// 默認的/bin/sh會引發一系列顯示及操作問題,修改爲bash即可
usermod -s /bin/bash mysql
// 修改用戶的主目錄[一般默認爲/home/username]
// useradd -m會自動創建
usermod -d /home/mysql mysql
-------------------------------
-------------------------------
// 提供mysql用戶root權限
// 修改/etc/sudoers文件
/*
# User privilege specification
root ALL=(ALL:ALL) ALL
mysql ALL=(ALL:ALL) ALL
# Members of the admin group may gain root privileges
%admin ALL=(ALL) ALL
# Allow members of group sudo to execute any command
%sudo ALL=(ALL:ALL) ALL
*/