您的当前位置:首页 >数据库 >一文总结MySQL数据库访问控制实现原理 正文

一文总结MySQL数据库访问控制实现原理

时间:2025-11-04 20:57:33 来源:网络整理编辑:数据库

核心提示

复制//针对root账号 setglobalvalidate_password_policy=0;--设置判断密码的标准基于密码的长度validate_password_leng

一文总结MySQL数据库访问控制实现原理
复制//针对root账号  set global validate_password_policy=0; --设置判断密码的文总问控标准基于密码的长度(validate_password_length)  grant all privilges on *.* to root@localhost identified by password;  grant all privilges on *.* to root@% identified by password; --根据具体情况决定是免费信息发布网否开启  //针对日常运维账号  grant select, insert, update, delete on database_name.* to hwb@% identified by password;  grant create,alter,drop,references on database_name.* to hwb@%;   grant create temporary tables on database_name.* to hwb@%;   grant index on database_name.* to hwb@%;   grant create view on database_name.* to hwb@%;   grant show view on database_name.* to hwb@%;   grant create routine on database_name.* to hwb@%; -- 查看存储过程、函数状态   grant alter routine on database_name.* to hwb@%; --删除存储过程、源码库数据函数  grant execute on database_name.* to hwb@%;  grant all privileges on mysql.* to hwb@% identified by password; --不增加不能对其他用户的库访函数或存储过程做操作  //针对应用连接账号  grant all privileges on database_name.* to hwb2@应用服务器IP identified by password;  grant all privileges on mysql.* to hwb2@应用服务器IP; --不增加无法对其他用户的网站模板函数或存储过程做操作  //针对只读账号(导出数据库权限)  grant select on database_name.* to hwbread@% identified by hwbread123;  grant select on mysql.* to hwbread@%;  grant show view on database_name.* to hwbread@%;  grant file on *.* to hwbread@%; --if database_name.* will ERROR 1221 (HY000): Incorrect usage of DB GRANT and GLOBAL PRIVILEGES  1.2.3.4.5.6.7.8.9.10.11.12.13.14.15.16.17.18.19.20.21.22.23.24.25.26.