mysql误删root用户恢复方法
装完数据库清理一些默认账号的时候不小心把root删除了,flush privileges 之后的新 root 忘了grant任何权限,查看mysqld选项里面有个 −−skip-grant-tables 复制代码 代码如下: mysql5.5手册说明如下 复制代码 代码如下: This option causes the server to start without using the privilege system at all,which gives anyone with access to the server unrestricted access to all databases. You can cause a running server to start using the grant tables again by executing mysqladmin flush-privileges or mysqladmin reload command from a system shell,or by issuing a MySQL FLUSH PRIVILEGES statement after connecting to the server. This option also suppresses loading of plugins,user-defined functions (UDFs),and scheduled events. To cause plugins to be loaded anyway,use the --plugin-load option. --skip-grant-tables is unavailable if MySQL was configured with the --disable-grant-options option. See Section 2.10.2,“Typical configure Options”. mysqld_safe是Unix/Linux系统下的MySQL服务器的一个启动脚本。这个脚本增加了一些安全特性,会在启动MySQL服务器以后继续监控其运行情况,并在出现错误的时候重新启动服务器。后台启动mysql 复制代码 代码如下: 如果没有root账户就添加一个 复制代码 代码如下: 直接输入mysql连接并添加权限,这时候是不能使用grant命令的,只能用update 复制代码 代码如下: 注意我用的是mysql是5.5版本,可能操作过程中sql语句或其他地方有不同,语句执行完毕之后需要flush privileges ,还可能要重新登录才行。 (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |