我正在创建一个 mysql 数据库,以便为一个高频访问的网站提供服务,我正在努力选择如何控制对该数据库的访问。网站的每个用户是否都应该拥有对该数据库的个人访问权限,或者网站应该访问数据库并为客户提供服务吗?
例如,如果我在网站中有 Mike 和 Stanley 用户,我是否应该在数据库中创建用户 'mike'@'localhost' 和 'stanley'@'localhost'?
或者我应该创建 'mywebuser'@'localhost' 来为这两个客户端提供服务,并有一个存储过程来检查它们访问数据库的能力吗?
最佳答案
For example, if I have Mike and Stanley users in the website, should I create users 'mike'@'localhost' and 'stanley'@'localhost' in the DB?
Or should I create 'mywebuser'@'localhost' to serve both these clients, having a stored procedure that will check on their ability to access the DB?
您肯定想为您的应用程序创建一个用户,而不是为您的应用程序的用户。出于安全原因,请务必仅向该用户授予必要的权限。对于仅在数据库中插入、更新、删除和选择内容的应用程序,您可能不需要 CREATE、ALTER 或 DROP 权限。
在 mysql 连接时检查用户的登录凭据需要您捕获连接期间抛出的 C 错误,即 generally a bad practice .
关于php - 我应该使用哪种数据库用户架构来为高频网站提供服务?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15222972/