首页 > 数据库 >The MySQL server is running with the --skip-grant-tables option so it cannot execute this statement

The MySQL server is running with the --skip-grant-tables option so it cannot execute this statement

时间:2023-05-25 16:14:25浏览次数:68  
标签:tables execute option skip flush USER MySQL 权限

 

The MySQL server is running with the --skip-grant-tables option so it cannot execute this statement

 

默认情况下,启动MySQL数据库实例期间,会读取所有的权限表条目到内存中,后续被缓存到内存中的权限条目作为依据即刻对后续的控制访问生效(传送门)。

使用"skip-grant-tables"启动MySQL数据库实例时,会禁用权限系统(MySQL privilege system),禁用身份验证检查(忘记root密码的常规重置操作,官档提供了此方式:传送门)。

这将导致无法使用如:"ALTER USER"、"CREATE USER"、"DROP USER"、"GRANT"、"REVOKE"、"SHOW GRANTS"等引起内部递归SQL后操作到权限表的DCL语法。

示例:

(root@ 15:31:09) [mysql]> create user 'test'@'%' identified by 'test';
ERROR 1290 (HY000): The MySQL server is running with the --skip-grant-tables option so it cannot execute this statement

 

 

此时可以通过flush privileges在线重新启动权限系统(MySQL privilege system),对于"FLUSH PRIVILEGES",详见:传送门

这是因为这里flush privileges会重新触发读取所有的权限表条目到内存中这个动作。

或者通过OS层面执行mysqladmin flush-privilegesmysqladmin reload达到同样的效果。

(root@ 15:45:45) [mysql]> flush privileges;
Query OK, 0 rows affected (0.01 sec)

(root@ 15:45:49) [mysql]> create user 'test'@'%' identified by 'test';
Query OK, 0 rows affected (0.01 sec)

 

 

实际上,这也是直接通过DML(delete/update/insert)操作授权表,(不重启数据库的前提下)需要执行"flush privileges"更新内存中权限条目达到即时生效的效果。

而通过"ALTER USER"、"CREATE USER"、"DROP USER"、"GRANT"、"REVOKE"等账户管理语句来直接间接修改权限时,服务器会注意到这些更改并立即将授权表再次加载到内存中。

详见:更改权限生效时机

防爬虫:https://www.cnblogs.com/PiscesCanon/p/17431610.html

标签:tables,execute,option,skip,flush,USER,MySQL,权限
From: https://www.cnblogs.com/PiscesCanon/p/17431610.html

相关文章

  • 找不到“element-plus/global”的类型定义文件。 程序包含该文件是因为: 在 compilerO
    问题描述在tsconfig.json文件里types字段添加"element-plus/global"后出现报错。问题原因TS升级到5.x带来的规范性问题。可以通过npmviewtypescriptversion命令查看下你的TS版本。深层分析参考这篇:https://github.com/element-plus/element-plus/issues/12119问题解决1......
  • 用jquery或js获取select标签中选中的option值及文本
    本文目录一、示例二、获取option的文本三、获取option中value的值四、代码展示一、示例<selectid="selectedTest"οnchange="doSomething();"><optionvalue="abc">北京</option><optionvalue="edf">上海</option><opt......
  • [Rust] Option vs Result
    OptionandResultaretwoverycentralenumsinRust,andtheyareusedforerrorhandlingandforrepresentingtheabsenceofavalue.Hereisabreakdownofboth:Option:AnOptionrepresentsanoptionalvalue:everyOptioniseitherSomeandcontain......
  • Failed to execute 'setSelectionRange' on 'HTMLInputElement'
    jcubic commented on7Jan2016WhenIusenumberinputI'vegoterrorinGoogleChromeUncaughtInvalidStateError:Failedtoexecute'setSelectionRange'on'HTMLInputElement':Theinputelement'stype('number')......
  • Warning: usage of --preserve-metadata with option "resource-rules" (deprecated i
    jenkins构建项目的时候报错:error1.Output:Warning:usageof–preserve-metadatawithoption“resource-rules”(deprecatedinMacOSX>=10.10)!报错原因:是因为Xcode自带的打包插件PackageApplication在MacOSX>=10.10的时候,不支持ResourceRules.plist的重签名打......
  • 学习笔记-Java8新特性-第五节-Optional类
    Optional类Optional<T>是一个容器类代表一个值存在或不存在致力于解决空指针异常问题(NPE)可以快速锁定发生NPE的位置(这东西真的好用吗?)常用方法Optional.of(Tt)创建一个Optional实例不能传入空指针,会报NPE使用Optional,报空指针了,说明就是这里的问题?......
  • elasticsearch 启动报错 SearchPhaseExecutionException[Failed to execute phase [qu
    Elasticsearch启动报错:[2023-05-19T22:39:32,161][DEBUG][o.e.a.s.TransportSearchAction][X-111.ecs]Allshardsfailedforphase:[query][2020-05-19T22:39:32,162][WARN][r.suppressed][X-111.ecs]path:/.kibana_task_manager/_search,params:{ign......
  • 人手一个 Midjourney,StableStudio 重磅开源!
    人手一个Midjourney,StableStudio重磅开源!StabilityAI公司在上个月19号推出了Alpha版本StableLM大语言模型,包含了30亿和70亿参数,并且支持商用。如今他们再次推出了AI图像生成平台StableStudio,这可是距上次大开发仅过去一个月啊!该平台是DreamStudio开源版的实......
  • k8s iptables链
    [root@k8s-masterdocker]#iptables-S-tnat-PPREROUTINGACCEPT-PINPUTACCEPT-POUTPUTACCEPT-PPOSTROUTINGACCEPT-NDOCKER-NKUBE-MARK-DROP-NKUBE-MARK-MASQ-NKUBE-NODEPORTS-NKUBE-POSTROUTING-NKUBE-SEP-2CJALHN5HAPMFVFM-NKUBE-SEP-3QOD56XR......
  • [Rust] Option
    fnmultiply(num:Option<usize>)->usize{returnnum.unwrap_or(0)*5;}fnmultiply1(num:Option<usize>)->Option<usize>{matchnum{Some(num)=>Some(num*5),None=>None,}}fnmultiply......