MySQL忘记root密码不重启mysqld的方法
 
1、首先得有一个可以拥有修改权限的mysql数据库账号,当前的mysql实例账号(较低权限的账号,比如可以修改zabbix数据库)或者其他相同版本实例的账号。把 data/mysql 目录下面的user表相关的文件复制到 data/zabbix 目录下面。
 
[root@restoredb mysql]# cp mysql/user.* test/
[root@restoredb mysql]# chown mysql.mysql test/user.*
 
2、使用另一个较低权限的账号链接数据库,设置 zabbix 数据库中的 user 存储的密码数据。
 
 
[root@restoredb mysql]# mysql -uzabbix -pzabbixpasswd -A 
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 1180
Server version: 5.7.22-log MySQL Community Server (GPL)
 
Copyright (c) 2000, 2018, 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> use zabbix;
Database changed
mysql> update user set authentication_string=password('zabbixpasswd') where user='root';
Query OK, 2 rows affected, 1 warning (0.04 sec)
Rows matched: 2 Changed: 2 Warnings: 1
 
 
3、把修改后的user.MYD和user.MYI复制到mysql目录下,记得备份之前的文件。
 
mv mysql/user.MYD mysql/user.MYD.bak
mv mysql/user.MYI mysql/user.MYI.bak
cp zabbix/user.MY* mysql/
chown mysql.mysql mysql/user.*
 
4、kill -SIGHUP 
 
[root@restoredb mysql]# pgrep -n mysql
31650
[root@restoredb mysql]#
[root@restoredb mysql]# kill -SIGHUP 31650
 
5、测试
[root@restoredb mysql]# mysql -uroot -pzabbixpasswd -A 
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 1190
Server version: 5.7.22-log MySQL Community Server (GPL)
 
Copyright (c) 2000, 2018, 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> 

MySQL忘记root密码不重启mysqld的方法的更多相关文章

  1. MySQL忘记root密码--不重启mysqd重置root密码

    先提个问题:如何不重启mysqld,且没有权限修改用户账号和权限的情况下,如何重新设置root密码?不知道没关系,在此之前我也是不知道如何操作的,先看看下面的几种重置root密码的方法. 1.skip ...

  2. MySQL 忘记root密码的两种处理方法

    [背景] 由于各个原因,我遇到过不只一次我服务的客户忘记了MySQL的root密码:如果是普通用户还好,我们可以用root用户去改它的密码,要命 的是把root给丢了! 对于MySQL来说如果你忘记了 ...

  3. linux下mysql忘记root密码怎么办

    Linux下MySQL忘记root密码怎么办? Linux下MySQL忘记root密码怎么办? 1. 修改MySQL配置文件 默认MySQL的配置文件为/etc/my.cnf,在[mysqld]下面添 ...

  4. 附录:MySQL忘记root密码

    中小型规模网站集群架构:MySQL忘记root密码 : 矮哥linux运维群:93324526 前言 你忘记系统root密码的时候,你怎么解决的? 不就是single用户进行修改密码吗?这里原理是类似 ...

  5. mysql忘记root密码的解决方法

    Windows下mysql忘记root密码的解决方法 1. 首先检查mysql服务是否启动,若已启动则先将其停止服务,可在开始菜单的运行,使用命令:net stop mysql 或者在windows任 ...

  6. mysql忘记root密码解决办法

    最近项目中的数据库我放在了服务器上,但是今天突然不能用了,进入服务器查看,果然是数据库不能进去了,所以今天来分享一个mysql忘记root密码的解决方案: 1.让mysql不载入权限表,命令:mysq ...

  7. MySQL 5.7 Command Line Client输入密码后闪退和windows下mysql忘记root密码的解决办法

    MySQL 5.7 Command Line Client输入密码后闪退的问题: 问题分析: 1.查看mysql command line client默认执行的一些参数.方法:开始->所有程序 ...

  8. Ubuntu下MySQL忘记root密码重置

    MySQL忘记root密码肿么办?-_-|||   这种情况虽然不是很常见,但是有时长时间没有登录系统,还真会忘记密码.这时候,如果您能以系统管理员权限登陆密码,那还是有救的.放大招,将其重置即可. ...

  9. windows下mysql忘记root密码的解决办法

    今天早上 一朋友说自己的mysql 忘记root密码了 让我帮忙给看看,因为没有接触过mysql 所以从网上找了一下信息经我亲身实践  已经成功!mysql版本是5.1以下是从网上找的信息: 1. 首 ...

随机推荐

  1. wap.css

    wap.css 一.总结 1.官方有教程:英语的 http://www.developershome.com/wap/wcss/ 2.wap.css :就是控制页面在手机端样式的 3.DOCTYPE ...

  2. Windows Forms 窗体篇

    1,显示窗体 非模式: Form form = new Form(); form.Show(); 模式: Form form = new Form(); form.Show(); 2,拥有者窗体与附属 ...

  3. AndroidStudio MAT LeakCanary 内存分析之 LeakCanary

    现在我们换一种更清晰方便的方式:LeakCanary https://github.com/square/leakcanary 首先将LeakCanary绑在我们的app上 build.gradle ...

  4. android 5.x system.img 大于2G导致编译otapackage时报错怎样处理

    当system分区预制过多apk时假设img size超过2G 在make otapackage时会报例如以下错误  zipfile.LargeZipFile: Zipfile size would ...

  5. fatfs的设置

    官方网址:file:///E:/%E5%8D%95%E7%89%87%E6%9C%BA/FATFS/ff13a/documents/doc/config.html 关于多个文件同时打开的配置::在ff ...

  6. 每日技术总结:vue router传参方式,js获取设备高度

    今天貌似没什么问题,23333…… 1.vue router 路由传参的方式 应用情景:从分类页(category.vue)进入商品列表页(list.vue),需要传递商品分类id(catId),商品 ...

  7. (转)Bash 快捷键 完整版

    转自:http://www.opsers.org/linux-home/base/full-version-of-bash-keyboard-shortcuts.html#toc-3 生活在 Bash ...

  8. HDU 1287 破译密码 异或运算

    http://acm.hdu.edu.cn/showproblem.php?pid=1287 题目: 有个叫"猪头帮"的国家,采用一种简单的文法加密,他们所用的语言里面只有大写字母 ...

  9. TensorFlow on Windows: “Couldn't open CUDA library cudnn64_5.dll”

    TensorFlow on Windows: "Couldn't open CUDA library cudnn64_5.dll" 在 windows 下,使用 import te ...

  10. 字典(dictionary)的设计

    1. 简单接口 struct Dict{ bool has(const string& key); void insert(const string& key, const strin ...