mysql误删root用户恢复方法
2015-02-13 00:00
746 查看
装完数据库清理一些默认账号的时候不小心把root删除了,flush privileges 之后的新 root 忘了grant任何权限,查看mysqld选项里面有个 −−skip-grant-tables
mysql5.5手册说明如下
mysqld_safe是Unix/Linux系统下的MySQL服务器的一个启动脚本。这个脚本增加了一些安全特性,会在启动MySQL服务器以后继续监控其运行情况,并在出现错误的时候重新启动服务器。后台启动mysql
如果没有root账户就添加一个
直接输入mysql连接并添加权限,这时候是不能使用grant命令的,只能用update
注意我用的是mysql是5.5版本,可能操作过程中sql语句或其他地方有不同,语句执行完毕之后需要flush privileges ,还可能要重新登录才行。
#/usr/libexec/mysqld --verbos --help
mysql5.5手册说明如下
--skip-grant-tables 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
#mysqld_safe --skip-grant-tables &
如果没有root账户就添加一个
INSERT INTO user SET User='root',Host='localhost',ssl_cipher='',x509_issuer='',x509_subject='';
直接输入mysql连接并添加权限,这时候是不能使用grant命令的,只能用update
UPDATE user SET Select_priv='Y',Insert_priv='Y',Update_priv='Y',Delete_priv='Y',Create_priv='Y',Drop_priv='Y',Reload_priv='Y',Shutdown_priv='Y',Process_priv='Y',File_priv='Y',Grant_priv='Y',References_priv='Y',Index_priv='Y',Alter_priv='Y',Show_db_priv='Y',Super_priv='Y',Create_tmp_table_priv='Y',Lock_tables_priv='Y',Execute_priv='Y',Repl_slave_priv='Y',Repl_client_priv='Y',Create_view_priv='Y',Show_view_priv='Y',Create_routine_priv='Y',Alter_routine_priv='Y', Create_user_priv='Y',Event_priv='Y',Trigger_priv='Y',Create_tablespace_priv='Y',authentication_string='' WHERE User='root';
注意我用的是mysql是5.5版本,可能操作过程中sql语句或其他地方有不同,语句执行完毕之后需要flush privileges ,还可能要重新登录才行。
相关文章推荐
- mysql误删root用户恢复方法
- mysql误删root用户或者忘记root密码解决方法
- 删除mysql的root用户恢复方法
- Ubuntu下误删或者误改mysql的root用户信息,解决方法
- mysql误删root用户或者忘记root密码解决方法
- mysql误删root用户或者忘记root密码解决方法
- 关于root(其他)用户拒绝登陆mysql的处理方法
- 解决误删Mysql中root所有权限的方法!
- mysql update完root用户密码后,再登陆报错”Access denied for user 'root'@'localhost' (using password: YES)“的解决方法
- Mac下新安装的MySQL无法登陆root用户解决方法
- Mac下新安装的MySQL无法登陆root用户解决方法
- ubuntu 忘记root用户及密码的恢复方法
- MYSQL用户root密码为空又一攻击方法
- Mysql误删root用户或没有root用户――linux
- MySQL修改root密码及恢复权限的多种方法
- MySQL重置root用户密码的方法
- 【MySQL】忘记root用户密码详细解决方法
- 防止mysql用户root密码弱口令的攻击方法
- 恢复Mysql丢失的root用户权限
- 在phpmyadmin中误删root用户!怎么恢复?