iis服务器助手广告广告
返回顶部
首页 > 资讯 > 数据库 >关于mysql中root权限丢失的问题
  • 977
分享到

关于mysql中root权限丢失的问题

2024-04-02 19:04:59 977人浏览 独家记忆
摘要

刚听一哥们说执行了一条语句:revoke all on *.* from root@localhost;            --呵呵,当时到底

刚听一哥们说执行了一条语句:revoke all on *.* from root@localhost;            --呵呵,当时到底是怎样的心理活动,这是怎样的恨。。。
于是小菜就做了一个实验,心里感觉应该和密码丢失后跳过权限重新设置密码的解决方法是一样的,当然这只是思路,试试才知道。
首先停止数据库[root@Mysql ~]#service mysql3306 stop                              --因为忘记密码所以只能停止服务的方式关闭数据库
Shutting down Mysql.                                       [  OK  ]
[root@mysql ~]#
[root@mysql ~]# /usr/local/mysql/bin/mysqld_safe  --defaults-file=/usr/local/mysql/etc/my.cnf  --skip-grant-tables &                         --跳过校验密码的方式启动数据库[2] 11254
[root@mysql ~]# 160330 16:56:22 mysqld_safe Logging to '/usr/local/mysql/log/err3306.log'.
160330 16:56:22 mysqld_safe Starting mysqld daemon with databases from /usr/local/mysql/data

[root@mysql ~]# ps -ef | grep mysql                                               --查看数据库已然启动
root      11254   6904  0 16:56 pts/2    00:00:00 /bin/sh /usr/local/mysql/bin/mysqld_safe --skip-grant-tables
mysql     11771  11254  0 16:56 pts/2    00:00:00 /usr/local/mysql/bin/mysqld --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data --plugin-dir=/usr/local/mysql/lib/plugin --user=mysql --skip-grant-tables --log-error=/usr/local/mysql/log/err3306.log --pid-file=/usr/local/mysql/data/mysql.lz.com.pid --Socket=/usr/local/mysql/mysqld3306.sock --port=3306
root      11795   6904  0 16:57 pts/2    00:00:00 grep mysql
[root@mysql ~]# /usr/local/mysql/bin/mysql --socket=/usr/local/mysql/mysqld3306.sock --port=3306                   --不指定用户和密码直接登录数据库
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.5.17-log Source distribution

Copyright (c) 2000, 2011, oracle and/or its affiliates. All rights reserved.

Oracle is a reGIStered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> select user();                                                --默认为root用户登录
+--------+
| user() |
+--------+
| root@  |
+--------+
1 row in set (0.00 sec)

root@master 08:41:31 >grant all on *.* to 'root'@'localhost';
ERROR 1290 (HY000): The MySQL Server is running with the --skip-grant-tables option so it cannot execute this statement  
在网上找到解决方法:

这个时候我们只需要

flush privileges 一下,在添加用户就OK了,

mysql> flush privileges;
Query OK, 0 rows affected (0.01 sec)

root@master 08:45:59 >grant all on *.* to 'ivan'@'localhost' identified by 'mysql321'  with grant option;
Query OK, 0 rows affected (0.01 sec)

root@master 08:46:24 >flush privileges;
Query OK, 0 rows affected (0.01 sec)

root@master 08:46:31 >quit
Bye
[root@mysql data]# service mysql3306 stop
Shutting down MySQL..160409 08:46:39 mysqld_safe mysqld from pid file /usr/local/mysql/mysql3306.pid ended
                                                           [  OK  ]
[1]+  Done                    /usr/local/mysql/bin/mysqld_safe --defaults-file=/usr/local/mysql/etc/my.cnf --skip-grant-tables
[root@mysql data]# ps -ef  |grep msyql
root      62709  57953  0 08:46 pts/1    00:00:00 grep msyql
[root@mysql data]# service mysql3306 start
Starting MySQL..                                           [  OK  ]
[root@mysql data]# /usr/local/mysql/bin/mysql -uivan -p
Enter passWord
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.5.17-log Source distribution

Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

ivan@master 08:47:36 >grant all on *.* to 'root'@'localhost' with grant option;
Query OK, 0 rows affected (0.00 sec)

[root@mysql data]# /usr/local/mysql/bin/mysql -uroot -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 9
Server version: 5.5.17-log Source distribution

Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

root@master 08:49:33 >show databases;
+--------------------+
| Database           |
+--------------------+
| infORMation_schema |
| c_test             |
| ivan               |
| mysql              |
| performance_schema |
| test               |
| WEBcat             |
+--------------------+
至此一切正常。。。。。啊哈哈哈哈。。。。


您可能感兴趣的文档:

--结束END--

本文标题: 关于mysql中root权限丢失的问题

本文链接: https://www.lsjlt.com/news/48981.html(转载时请注明来源链接)

有问题或投稿请发送至: 邮箱/279061341@qq.com    QQ/279061341

本篇文章演示代码以及资料文档资料下载

下载Word文档到电脑,方便收藏和打印~

下载Word文档
猜你喜欢
  • 关于mysql中root权限丢失的问题
    刚听一哥们说执行了一条语句:revoke all on *.* from root@localhost;            --呵呵,当时到底...
    99+
    2024-04-02
  • 关于vuex强刷数据丢失问题解析
    vuex-persistedstate 核心原理:在本地存储中存入所有的vuex数据,页面刷新时到缓存中取数据,放到vuex中 下载:$ npm install ...
    99+
    2024-04-02
  • 关于vuex强刷数据丢失问题的解决方法
    这篇文章主要讲解了“关于vuex强刷数据丢失问题的解决方法”,文中的讲解内容简单清晰,易于学习与理解,下面请大家跟着小编的思路慢慢深入,一起来研究和学习“关于vuex强刷数据丢失问题的解决方法”吧!vuex-persistedstate核心...
    99+
    2023-06-14
  • MySQL中怎么开启root远程访问权限
    这篇文章将为大家详细讲解有关MySQL中怎么开启root远程访问权限,文章内容质量较高,因此小编分享给大家做个参考,希望大家阅读完这篇文章后对相关知识有一定的了解。MySQL开启root远程访问权限&nbs...
    99+
    2024-04-02
  • 【Linux】关于Linux中的权限
    文章目录 前言Linux权限文件访问者的分类(人)文件类型和访问权限(事物属性)文件类型基本权限 目录的权限粘滞位权限的总结 前言 前面我们已经知道。Linux下有两种用户:超级...
    99+
    2023-09-24
    linux 服务器 运维
  • 关于ACCESS_BACKGROUND_LOCATION权限申请,导致不弹权限对话框的问题记录
    Android 6.0以后,对于需要动态申请的权限,一般步骤如下: 在Manifest中添加相应权限; 2.使用ActivityCompat或者ContextCompat的checkSelfPer...
    99+
    2023-09-02
    android
  • 关于Redis未授权访问的问题
    目录漏洞原理利用条件漏洞危害漏洞复现搭建测试环境攻击机Kali 2021.1利用redis写入webshell利用redis反弹shell利用redis写入ssh公钥总结漏洞原理 R...
    99+
    2024-04-02
  • Spring关于@Scheduled限制的问题
    目录Spring @Scheduled限制Spring多定时任务@Scheduled执行阻塞一. 问题描述二. 场景复现三. 解决方案四. 总结Spring @Scheduled限制...
    99+
    2024-04-02
  • 关于vue中根据用户权限动态添加路由的问题
    根据用户的权限,展示不同的菜单页。 知识点 路由守卫(使用了前置守卫):根据用户角色判断要添加的路由 vuex:保存动态添加的路由 难点 每次路由发生变化时都需要调用一次路由守卫,...
    99+
    2024-04-02
  • 关于Spring Boot动态权限变更问题的实现方案
    1、前言 ​  在Web项目中,权限管理即权限访问控制为网站访问安全提供了保障,并且很多项目使用了Session作为缓存,结合AOP技术进行tok...
    99+
    2024-04-02
  • 关于ConditionalOnMissingBean失效问题的追踪
    目录现场回放services操作类configuration抛出异常问题定位工作原理问题出在哪 解决问题结论遇到一个@ConditionalOnMissingBean失效的...
    99+
    2024-04-02
  • 关于JAVA SOCKET UDP的高并发丢包问题
    在使用Java Socket进行UDP通信时,可能会遇到高并发丢包的问题。这是因为UDP协议是一种无连接的协议,不保证数据包的可靠传...
    99+
    2023-08-18
    Java
  • 如何解决Ubuntu root系统权限的静态IP问题
    本篇文章给大家分享的是有关如何解决Ubuntu root系统权限的静态IP问题,小编觉得挺实用的,因此分享给大家学习,希望大家阅读完这篇文章后可以有所收获,话不多说,跟着小编一起来看看吧。Ubuntu root是经常用到的,于是我研究了一下...
    99+
    2023-06-16
  • Vue关于访问外链失败的问题
    目录Vue访问外链失败什么是 referrer ?隐私安全Vue打开一个外部连接总结Vue访问外链失败 在公司项目中,点击跳转外部链接时,发现跳转失败,但是在浏览器访问可以直接访问,...
    99+
    2023-03-11
    Vue访问外链失败 Vue访问外链 Vue外链访问
  • 关于docker cgroups资源限制的问题
    目录一、cpu资源控制1、 设置cpu使用率上限2、设置cpu资源占用比(设置多个容器时才有效)3、设置容器绑定指定的CPU三、内存资源控制四、磁盘IO配额控制1、限制Block I...
    99+
    2024-04-02
  • MySQL存储过程的权限问题小结
    MySQL的存储过程,没错,看起来好生僻的使用场景。问题源于一个开发同学提交了权限申请的工单,需要开通一些权限。 本来是一个很正常的操作,但在我来看是比较着急且紧迫的,说来惭愧,忙着方向规划和开发的事情,这...
    99+
    2024-04-02
  • 新手小白解决MySql里root(根用户)权限(最高权限)丢失的解决办法及恢复办法------个人意见仅供参考
    目录 问题由来缺失权限而导致的报错和常见报错报错解析具体解决办法总结 问题由来 在一次对mysql用户权限进行管理时不慎将root的权限删除,由于是新手小白并不了解root权限是最高权...
    99+
    2023-10-06
    mysql 数据库 服务器
  • mysql中怎么设置root用户的密码和权限
    这篇文章主要介绍了mysql中怎么设置root用户的密码和权限的相关知识,内容详细易懂,操作简单快捷,具有一定借鉴价值,相信大家阅读完这篇mysql中怎么设置root用户的密码和权限文章都会有所收获,下面我...
    99+
    2023-05-25
    mysql root
  • Windows安装MySQL后怎么开启root的网络访问权限
    Windows安装mysql后怎么开启root的网络访问权限 Windows安装MySQL后默认只能本机访问,怎么开启网络访问 mysql> create user 'root'@'%' identified by...
    99+
    2023-08-20
    Windows安装MySQL mysql外网访问
  • mysql中如何使用root用户分配其它用户访问权限
    这篇文章主要介绍mysql中如何使用root用户分配其它用户访问权限,文中介绍的非常详细,具有一定的参考价值,感兴趣的小伙伴们一定要看完!使用root用户分配其它用户访问权限/usr/local/mysql...
    99+
    2024-04-02
软考高级职称资格查询
编程网,编程工程师的家园,是目前国内优秀的开源技术社区之一,形成了由开源软件库、代码分享、资讯、协作翻译、讨论区和博客等几大频道内容,为IT开发者提供了一个发现、使用、并交流开源技术的平台。
  • 官方手机版

  • 微信公众号

  • 商务合作