忘记mysql root管理员帐号密码处理方法
点击阅读原文,提升阅读体验: https://www.modb.pro/db/22826?cyn
摘要:丢失root密码,意味着不能以超级管理员帐号登录数据库,进行维护工作。需要找回root密码。
概述
丢失root密码,意味着不能以超级管理员帐号登录数据库,进行维护工作。需要找回root密码。
处理方法
杀掉mysql进程,然后添加一个参数–skip-grant-tables跳过权限表,启动mysql实例,然后以无密码方式登录数据库,修改root用户密码,再关闭mysql实例(关闭或者kill mysql进程),最后正常启动mysql实例,就可以使用root用户登录数据库了。
关键操作代码
点击阅读原文,提升阅读体验: https://www.modb.pro/db/22826?cyn
mysql -uroot -p
ps -ef|grep mysql
kill -9 mysql进程号
mysqld_safe --defaults-file=/etc/my.cnf --skip-grant-tables &
mysql
use mysql;
update user set authentication_string=password(‘oracle123’) where user=‘root’;
flush privileges;
mysqladmin -p shutdown
mysqld_safe --defaults-file=/etc/my.cnf &
mysql -uroot -p
操作演示日志
[root@source ~]# mysql -uroot -p Enter password: ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES) ==故意输错密码,模拟root密码丢失== [root@source ~]# [root@source ~]# ps -ef|grep mysql root 6733 6191 0 10:28 pts/0 00:00:00 /bin/sh /usr/local/mysql/bin/mysqld_safe --defaults-file=/etc/my.cnf mysql 7029 6733 2 11:10 pts/0 00:00:00 /usr/local/mysql/bin/mysqld --defaults-file=/etc/my.cnf --basedir=/usr/local/mysql --datadir=/data/mysql --plugin-dir=/usr/local/mysql/lib/plugin --user=mysql --log-error=source.err --pid-file=source.pid --port=3306 root 7063 6191 0 11:10 pts/0 00:00:00 grep mysql [root@source ~]# [root@source ~]# kill -9 7029 6733 [root@source ~]# [1]+ Killed mysqld_safe --defaults-file=/etc/my.cnf [root@source ~]# [root@source ~]# ps -ef|grep mysql root 7066 6191 0 11:10 pts/0 00:00:00 grep mysql [root@source ~]# [root@source ~]# [root@source ~]# mysqld_safe --defaults-file=/etc/my.cnf --skip-grant-tables & [1] 7286 [root@source ~]# 2020-02-16T03:11:41.998645Z mysqld_safe Logging to '/data/mysql/source.err'. 2020-02-16T03:11:42.020962Z mysqld_safe Starting mysqld daemon with databases from /data/mysql [root@source ~]# [root@source ~]# mysql Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 3 Server version: 5.7.20-log MySQL Community Server (GPL) Copyright (c) 2000, 2017, 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@db 11:11: [(none)]> root@db 11:11: [(none)]> root@db 11:12: [(none)]> root@db 11:12: [(none)]> use mysql; Database changed root@db 11:12: [mysql]> root@db 11:12: [mysql]> update user set authentication_string=password('oracle123') where user='root'; ==修改密码== Query OK, 1 row affected, 1 warning (0.01 sec) Rows matched: 2 Changed: 1 Warnings: 1 root@db 11:13: [mysql]> root@db 11:13: [mysql]> flush privileges; Query OK, 0 rows affected (0.00 sec) root@db 11:13: [mysql]> root@db 11:14: [mysql]> exit Bye [root@source ~]# [root@source ~]# mysqladmin -p shutdown Enter password: [root@source ~]# [root@source ~]# 2020-02-16T03:15:27.217666Z mysqld_safe mysqld from pid file /data/mysql/source.pid ended [1]+ Done mysqld_safe --defaults-file=/etc/my.cnf --skip-grant-tables [root@source ~]# [root@source ~]# ps -ef|grep mysql root 7502 6191 0 11:15 pts/0 00:00:00 grep mysql [root@source ~]# [root@source ~]# mysqld_safe --defaults-file=/etc/my.cnf & [1] 7503 [root@source ~]# 2020-02-16T03:15:57.181920Z mysqld_safe Logging to '/data/mysql/source.err'. 2020-02-16T03:15:57.217614Z mysqld_safe Starting mysqld daemon with databases from /data/mysql [root@source ~]# [root@source ~]# mysql -uroot -p Enter password: ==root密码找回后,正常登录== Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 4 Server version: 5.7.20-log MySQL Community Server (GPL) Copyright (c) 2000, 2017, 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@db 11:16: [(none)]>
忘记mysql root管理员帐号密码处理方法相关推荐
- linux路由修改密码,Linux中修改Mysql root用户密码的方法
Linux中修改Mysql root用户密码的方法 下面给大家分享下在Linux下如何修改Mysql的用户(root)的密码,分两种情况:第一种当拥有原来的mysql的root密码,第二种情况忘记原来 ...
- ubuntu 破解mysql密码_Ubuntu下忘记MySQL root密码解决方法
Linux下忘记MySQL root密码解决方法 忘了mysql密码,从网上找到的解决方案记录在这里. 编辑mysql的配置文件/etc/mysql/my.cnf,在[mysqld]段下加入一行&qu ...
- MySQL重置root用户密码的方法
MySQL重置root用户密码的方法 转自:http://www.xunmeinet.com/help/info.asp?id=45 本教程适用于采用Win2003.WinXP操作系统的迅美VPS和云 ...
- linux忘记mysql密码_linux下忘记mysql root密码解决办法 | 系统运维
引言:在linux系统中,如果忘记了MySQL的root密码,有没有办法重新设置新密码呢? 答案是肯定的,下面教大家一个比较简单的重置MySQL root密码的办法: 1.编辑MySQL配置文件my. ...
- win10下mysql root用户密码忘记的解决方式
win10下mysql root用户密码忘记的解决方式 点击电脑左下角的搜索图标,在搜索框中输入:cmd,并单击回车键: 右键点击桌面左下角的开始按钮,在弹出的菜单中选择运行菜单项,在打开的windo ...
- Ubuntu 18.04 忘记 mysql root密码及其重置
1.停止mysql服务 $ service mysql stop 2.修改 /etc/mysql/my.cnf 文件 # 修改my.cnf文件,在文件新增 skip-grant-tables,在启动m ...
- mysql密码一般设置什么格式_mysql更改密码_如何更改mysql root用户密码
windows平台下如何修改mysql数据库密码 1.关闭正在运行的MySQL服务:net stop mysql或 在windows 任务管理器中结束 mysqld.exe 进程或在 管理工具里面的服 ...
- php mysql 修改密码_设置及修改MySQL root用户密码
设置及修改MySQL root用户密码 MySQL数据库用户安全策略介绍 安装mysql数据库后,默认的管理员root密码是空,这很不安全,因此需要设置一个密码 为root设置密码 删除无用的MySQ ...
- mysql 重置root_MySQL 重置Mysql root用户账号密码
重置Mysql root用户账号密码 By:授客QQ:1033553122 问题描述: 使用mysqladmin.exe执行命令时出现以下错误提示: mysqladmin: connect to se ...
最新文章
- 2018年4月26日笔记
- [踏得网]HTML5在线教程阅读进度记录
- Common Attention Points
- 对EditText右边的图片进行监听
- count相加 sqlserver_mssql sqlserver sum(1)、sum(2)、count(1)、count(8)、count(*)、统计函数应用区别简介...
- php数组foreach循环添加键值对_php 给数组增加键值对
- flask页面操作gpn接口
- Pytorch高阶API示范——线性回归模型
- iOS中事件的传递和响应者链条
- 基于JAVA+SpringMVC+Mybatis+MYSQL的疫情防控物业管理系统
- MySQL的启动脚本
- rabbitMQ概念详细介绍
- 写好数学建模竞赛论文的那些事
- github followers-following相互比较
- 【python实战】怎么用python自动登录CSDN
- [图形学] 经典算法 - Kajiya三维纹理渲染毛发
- 孙鑫老师 java从入门到精通 视频教程 批量下载
- Java多进程从头讲到尾,值得收藏!
- 【verbs】ibv_get_async_event()
- 普通域账户不能运行金山打字通的解决方案
热门文章
- 开源linux_15本书(适合(希望)喜欢Linux和开源的孩子)
- raspberry pi_Raspberry Pi在单板计算机,新的符合FCC规则的路由器芯片等众多清单上排名第一
- MySQL有什么新功能?
- 测试项目开源_测验您对开源的承诺
- ubuntu 应用程序菜单_Ubuntu智能手机,塔式无人机飞行控制应用程序等
- 什么是openstack_谁是OpenStack大使?
- 装逼 | 10个JS精简代码无形装逼集合,最为致命,记得收藏好
- JavaScript实现斐波那契数列(Febonacci Array)
- android 字符串 时间格式化,Android 获取年月日时分秒 格式化指定时间字符串
- BZOJ1061 NOI2008 志愿者招募 线性规划、费用流