限制普通用户在huago_production_tool数据库上的权限

This commit is contained in:
luoliangyi 2022-12-12 12:01:12 +08:00
parent c6a0a02c10
commit 4f568b20ab
2 changed files with 5 additions and 5 deletions

View File

@ -312,7 +312,7 @@ HGResult HGPdtToolDbUserMgrImpl::CreateUser(const HGChar* userName, const HGChar
return HGBASE_ERR_FAIL;
}
sprintf(sqlCmd, "grant all privileges on huago_production_tool.* to '%s'@'%%';", userName);
sprintf(sqlCmd, "grant create, insert, select, update on huago_production_tool.* to '%s'@'%%';", userName);
ret = mysql_query(m_sql, sqlCmd);
assert(0 == ret);
sprintf(sqlCmd, "grant select on mysql.user to '%s'@'%%';", userName);

View File

@ -5,17 +5,17 @@
int main()
{
HGPdtToolDbUserMgr userMgr = NULL;
HGPdtToolDb_CreateUserMgr("127.0.0.1", 3306, "huago", "123456", &userMgr);
HGPdtToolDb_CreateUserMgr("127.0.0.1", 3306, "root", "123456", &userMgr);
if (NULL != userMgr)
{
HGChar* name[256];
HGUInt count;
HGPdtToolDb_GetUserList(userMgr, name, 256, &count);
//HGPdtToolDb_DestroyUser(userMgr, "huago");
HGPdtToolDb_DestroyUser(userMgr, "huago");
//HGPdtToolDb_CreateUser(userMgr, "huago", "123456");
HGPdtToolDb_ModifyPassword(userMgr, "123456", "huago");
HGPdtToolDb_CreateUser(userMgr, "huago", "123456");
//HGPdtToolDb_ModifyPassword(userMgr, "123456", "huago");
//HGPdtToolDb_SetPassword(userMgr, "huago", "qqq");
HGPdtToolDbDevice device = NULL;