mysql03--误删除了所有用户解决办法
误删除了所有用户解决办法
第一种方法(企业常用)
1.将数据库down掉
[root@db03 mysql]# /etc/init.d/mysqld stop
Shutting down MySQL.. SUCCESS!
[root@db03 mysql]# mysql
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/opt/mysql-5.6.44/tmp/mysql.sock' (2)
2.给/opt/目录下所有受mysql用户权限
[root@db03 mysql]# chown -R mysql.mysql /opt/*
3.启动数据库
[root@db03 ~]# mysqld_safe --skip-grant-tables --skip-networking &
4.进入数据库
[root@db03 ~]# mysql
5.初始化
mysql> flush privileges;
Query OK, 0 rows affected (0.01 sec)
6.设置数据库用户权限和密码
mysql> grant all on *.* to root@'localhost' identified by '1' with grant option;
Query OK, 0 rows affected (0.00 sec)
7.退出重启数据库
mysql> \q
[root@db03 mysql]# /etc/init.d/mysqld restar
8.进入数据库查看
mysql> select user,host from mysql.user;
+------+-----------+
| user | host |
+------+-----------+
| root | localhost |
+------+-----------+
1 row in set (0.01 sec)
第二种方法
1.down掉数据库
[root@db04 scripts]# /etc/init.d/mysqld stop
Shutting down MySQL.. SUCCESS!
2.启动数据库
[root@db04 scripts]# mysqld_safe --skip-grant-tables --skip-networking & [1] 25934
3.进入数据库
[root@db04 scripts]# mysql
4.使用数据库
mysql> use mysql
Reading table information for completion of table and column names You can turn off this feature to get a quicker startup with -A Database changed
5.创建root用户
mysql> insert into mysql.user values ('localhost','root',PASSWORD('123'),
-> 'Y',
-> 'Y',
-> 'Y',
-> 'Y',
-> 'Y',
-> 'Y',
-> 'Y',
-> 'Y',
-> 'Y',
-> 'Y',
-> 'Y',
-> 'Y',
-> 'Y',
-> 'Y',
-> 'Y',
-> 'Y',
-> 'Y',
-> 'Y',
-> 'Y',
-> 'Y',
-> 'Y',
-> 'Y',
-> 'Y',
-> 'Y',
-> 'Y',
-> 'Y',
-> 'Y',
-> 'Y',
-> 'Y',
-> '',
-> '',
-> '',
-> '',0,0,0,0,'mysql_native_password','','N');
6.查看用户
mysql> select user,host from mysql.user;
+------+-----------+
| user | host |
+------+-----------+
| root | localhost |
+------+-----------+
1 row in set (0.00 sec)
第三种方法(企业不可用,数据会丢失)
1.down掉数据库
[root@db04 ~]# /etc/init.d/mysqld stop
Shutting down MySQL.. SUCCESS!
2.删除或改名/opt/mysql/data目录
[root@db04 opt]# cd mysql
[root@db04 mysql]# mv data date
[root@db04 mysql]# rm -fr data
3.初始化
[root@db04 scripts]# ./mysql_install_db --datadir=/opt/mysql/data --basedir=/opt/mysql -- user=mysql
[root@db04 scripts]# echo $?
0
4.授权
[root@db04 scripts]# chown -R mysql.mysql /opt/*
5.启动数据库
[root@db04 scripts]# /etc/init.d/mysqld start
Starting MySQL.Logging to '/opt/mysql/data/db04.err'. SUCCESS!
6.进入数据库查看
[root@db04 scripts]# mysql
mysql> select user,host from mysql.user;
+------+-----------+
| user | host |
+------+-----------+
| root | % |
| root | 127.0.0.1 |
| root | ::1 |
| | db02 |
| root | db02 |
| | localhost |
| root | localhost |
+------+-----------+
7 rows in set (0.00 sec)
mysql03--误删除了所有用户解决办法的更多相关文章
- 误删除 mySQL 用户解决办法
误删除用户解决办法 删除用户 删除用户 mysql> truncate mysql.user;Query OK, 0 rows affected (0.05 sec)mysql> sel ...
- Sql Server 孤立用户解决办法
Sql Server 孤立用户 是我们经常遇到的事情,今天详细的梳理了下,希望能帮到你 当把用户数据库从一台 Sql Server 使用备份和恢复的方式迁移到另一台服务器.数据库恢复以后,原先用户定义 ...
- Oracle 学习笔记3:新建数据库没有scott用户解决办法
新建一个数据库,若选择Oracle组件时,没有选择实例方案,完成后进行口令管理,默认列表中是找不到scott用户解锁的.若要解锁scott用户,可以进行如下操作: 使用system或者sys连接数据库 ...
- centos误删mysql root用户找回办法
一天,我进入mysql后,查看所有用户 select host,user from mysql.user; 发现好多用户名, 太乱了,删除..... delete from user where us ...
- 误删/usr文件夹解决办法
http://blog.chinaunix.net/uid-2623904-id-3044156.html http://www.centoscn.com/CentOS/Intermediate/20 ...
- centos7误删yum源的解决办法 ( -bash: yum: command not found)
这里以安装阿里的yum源为例: 1.查看自己的centos版本 cat /etc/redhat-release 2.进入阿里云源站地址:http://mirrors.aliyun.com/centos ...
- Oracle数据库误删文件导致rman备份报错RMAN-06169解决办法
Oracle数据库误删文件导致rman备份报错RMAN-06169解决办法 可能是误删文件导致在使用rman备份时候出现以下提示 RMAN-06169: could not read file hea ...
- mac 安装mysql + 修改root用户密码 + 及报Access denied for user 'root'@'localhost' (using password:YES)解决办法
1.下载MySQL 到mysql的官网http://dev.mysql.com/downloads/mysql/然后在页面中会看到“MySQL Community Server”下方有一个“downl ...
- "SQLServer无法打开用户默认数据库,登录失败,错误4064"的解决办法
"SQLServer无法打开用户默认数据库,登录失败,错误4064"的解决办法 1.检查登录密码 如果密码错误,修改数据库密码,用windows身份验证登录进去, (1)安全--登 ...
随机推荐
- 前端VUE环境构建
https://nodejs.org/en/ 安装node 安装淘宝npm镜像 D:\>cd cnpm D:\cnpm>npm install -g cnpm --registry=htt ...
- Python---基础-小游戏用户猜数字2
一.使用int()将小数转换成整数,结果是向上取数还是向下取数 int(3,4) print(int(3,4)) ####写一个程序,判断给定年份是否为闰年 - 闰年的定义,能够被4整除的年份就叫闰年 ...
- Python---字符串拼接和严格字符串
BIF内建函数 Python3中提供了多少个内置函数 68 Python3中TUling tuling是不是一样的 严格区别大小 “=”和“==”的运用与区别 - ‘=‘ 是用来赋值的 - ...
- ng mvc + @Valid + @RequestBody 接收json同时校验javaBean的数据有效性
@Valid @RequestBody CustomerDto customerBean @RequestMapping(value="/customerDataSync.do", ...
- git使用技巧总结
一.把github上的代码下载下来 git clone ...... 二.把修改的代码提交上去 git add .... git commit -m "........" git ...
- asp.net大文件断点续传
以ASP.NET Core WebAPI 作后端 API ,用 Vue 构建前端页面,用 Axios 从前端访问后端 API ,包括文件的上传和下载. 准备文件上传的API #region 文件上传 ...
- log4j file 路径
默认以System.getProperty("user.dir")为准 用LOGGER.warn(System.getProperty("user.dir")) ...
- jinjia2 模板学习
参考链接https://blog.csdn.net/langkew/article/details/51734423
- drawRect
1) 画笔设置 Paint.Style.STROKE 中空模式 paint = new Paint(); //新建一个画笔对象 paint.setAntiAlias(true);//抗锯齿功能 pai ...
- C#如何获取系统downloads和documents路径
https://stackoverflow.com/questions/7672774/how-do-i-determine-the-windows-download-folder-path 如果你通 ...