[mysql] 2024-12-09 圈点756
摘要:mariadb如何在命令行下修改用户的权限的步骤
mariadb如何在命令行下修改用户的权限的步骤:
1,创建用户命令
mysql>CREATE USER 'mygod'@'%' IDENTIFIED BY 'aaaaaaaaaa';
2,修改授权的命令
2.1,增加权限命令
GRANT ALL ON `dbname`.`tbname` TO 'mygod'@'%' GRANT ALL ON `dbname`.* TO 'mygod'@'%' GRANT ALL ON *.* TO 'mygod'@'%' GRANT SELECT,INSERT,UPDATE,DELETE ON *.* TO 'mygod'@'%'
2.2删除权限命令
REVOKE ALL ON *.* FROM 'mygod'@'%' REVOKE SELECT,INSERT,UPDATE,DELETE ON *.* FROM 'mygod'@'%'
3,查看用户状态和权限
select User, host from mysql.user;
show grants for username;
注意:
%表示针对所有IP,
password表示将用这个密码登录root用户,
如果想只让某个IP段的主机连接,可以修改为:
GRANT ALL PRIVILEGES ON *.* TO 'root'@'192.168.71.%' IDENTIFIED BY 'my-new-password' WITH GRANT OPTION;
3,非常重要的一步:更新
FLUSH PRIVILEGES;