Loading [MathJax]/jax/output/CommonHTML/config.js
首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >专栏 >【MySQL】mysql忘记root密码

【MySQL】mysql忘记root密码

作者头像
用户5522200
发布于 2019-06-02 07:22:44
发布于 2019-06-02 07:22:44
6K0
举报
文章被收录于专栏:lindalinda

mysql数据库忘记root密码的解决方法,步骤如下

① # vim /etc/my.cnf 在[mysqld]下添加skip-grant-tables,然后保存并退出 ② 重启mysql服务:service mysqld restart ③ 执行 mysql 命令进入数据库,修改数据库密码 MySQL> UPDATE mysql.user SET Password=PASSWORD('新密码') where USER='root'; 如果是MySQL5.7,需要改为MySQL> UPDATE mysql.user SET authentication_string=PASSWORD('新密码') where USER='root'; mysql> flush privileges; ④ 把/etc/my.cnf中的skip-grant-tables注释掉,然后重启mysql, 即:service mysqld restart ⑤ 下面就可以用root新的密码登录了

代码语言:javascript
AI代码解释
复制
[root@ops04 scripts]# vim /etc/my.cnf
[root@ops04 scripts]# service mysqld restart
Restarting mysqld (via systemctl):                         [  OK  ]
[root@ops04 scripts]# 
[root@ops04 scripts]# mysql
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 4
Server version: 10.1.22-MariaDB MariaDB Server

Copyright (c) 2000, 2016, Oracle, MariaDB Corporation Ab and others.

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

MariaDB [(none)]> 
MariaDB [(none)]> set password=password('000000');
ERROR 1290 (HY000): The MariaDB server is running with the --skip-grant-tables option so it cannot execute this statement
MariaDB [(none)]> UPDATE mysql.user SET Password=PASSWORD('000000') where USER='root';
Query OK, 4 rows affected (0.00 sec)
Rows matched: 4  Changed: 4  Warnings: 0

MariaDB [(none)]> flush privileges;
Query OK, 0 rows affected (0.00 sec)

MariaDB [(none)]> exit
Bye
[root@ops04 scripts]# vim /etc/my.cnf
[root@ops04 scripts]# service mysqld restart
Restarting mysqld (via systemctl):                         [  OK  ]
[root@ops04 scripts]# 
[root@ops04 scripts]# mysql -uroot -p000000
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 4
Server version: 10.1.22-MariaDB MariaDB Server

Copyright (c) 2000, 2016, Oracle, MariaDB Corporation Ab and others.

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

MariaDB [(none)]> 
本文参与 腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。
如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
暂无评论
推荐阅读
编辑精选文章
换一批
MySQL root密码忘记,原来还有更优雅的解法!
一直以来,对于MySQL root密码的忘记,以为只有一种解法-skip-grant-tables。
星哥玩云
2022/08/16
4160
MySQL忘记root密码处理
如果忘记密码,对于MySQL而言处理起来也相对比较简单。但需要修改配置,重启数据库。可以按照如下步骤处理。
俊才
2020/01/17
4.7K0
MySQL常见问题一
这个错误一般发生在mysql 5.7以及 5.7以上的版本中,其原因是mysql的默认配置中,sql_mode="ONLY_FULL_GROUP_BY" 这个配置严格执行了 'SQL92标准',
soundhearer
2020/10/16
7750
MySQL常见问题一
CentOS 7安装 MySQL5.7.19
wget  https://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-5.7.19-linux-glibc2.12-x86_64.tar.gz
星哥玩云
2022/08/13
3790
Mysql数据库--修改root密码的几种方法(忘记密码&知道密码)
????一、知道密码情况–修改root密码 ⛳ 1.1 方式1:alter 命令修改 ???? 通过alter user root identified by '新密码';
老K博客
2023/12/18
2.5K0
Mysql数据库--修改root密码的几种方法(忘记密码&知道密码)
排障集锦:九九八十一难之第七难!mysql数据库登录密码忘记了
vim /etc/my.cnf 进入到配置文件 skip-grant-tables 加上此字段 跳过密码直接登录 登录后对mysql库中的user表中authentication_string 密码字段进行更改
不吃小白菜
2020/09/03
9590
忘记MySQL/MariaDB root密码的解决方法
MySQL/MariaDB 的root 密码忘了,不知道改怎么办,下面是修改root 密码步骤。
星哥玩云
2022/08/18
1.2K0
mysql 更改密码 alter_MySQL修改账号密码方法大全「建议收藏」
在日常使用数据库的过程中,难免会遇到需要修改账号密码的情景,比如密码太简单需要修改、密码过期需要修改、忘记密码需要修改等。本篇文章将会介绍需要修改密码的场景及修改密码的几种方式。
全栈程序员站长
2022/09/21
4.9K0
Linux 安装配置MariaDB
[root@dbServer ~]# yum install -y mariadb mariadb-server 已加载插件:fastestmirror Loading mirror speeds from cached hostfile  * base: mirrors.aliyun.com  * extras: mirrors.aliyun.com  * updates: mirrors.aliyun.com ........  ----------------------------------------------------------------------------------------------------------------------- 总计                                                                                                                                         1.8 MB/s |  20 MB  00:00:11      Running transaction check Running transaction test Transaction test succeeded Running transaction   正在安装    : 1:mariadb-libs-5.5.52-1.el7.x86_64                                                                                                                       1/4   正在安装    : perl-DBD-MySQL-4.023-5.el7.x86_64                                                                                                                        2/4   正在安装    : 1:mariadb-5.5.52-1.el7.x86_64                                                                                                                            3/4   正在安装    : 1:mariadb-server-5.5.52-1.el7.x86_64                                                                                                                     4/4   验证中      : 1:mariadb-server-5.5.52-1.el7.x86_64                                                                                                                     1/4   验证中      : perl-DBD-MySQL-4.023-5.el7.x86_64                                                                                                                        2/4   验证中      : 1:mariadb-5.5.52-1.el7.x86_64                                                                                                                            3/4   验证中      : 1:mariadb-libs-5.5.52-1.el7.x86_64                                                                                                                       4/4 已安装:   mariadb.x86_64 1:5.5.52-1.el7                        
程裕强
2022/05/06
1.2K0
Linux下MySQL忘记root密码的完美解决方法
在使用MySQL数据库时,由于某些原因长时间没有登陆MySQL,或者由于工作交接完成度不高,导致数据库root登陆密码忘记,本文给大家介绍一种当忘记MySQL root密码时的解决办法,亲测有效。
星哥玩云
2022/08/16
3.2K0
Linux下MySQL忘记root密码的完美解决方法
CentOS7 下 MySQL 5.7 重置root密码
本文节选自《Netkiller MySQL 手札》 CentOS 7.x 添加 skip-grant-tables=1 选项,然后重启mysql # cat /etc/my.cnf # For advice on how to change settings please see # http://dev.mysql.com/doc/refman/5.6/en/server-configuration-defaults.html [mysqld] # # Remove leading # and set
netkiller old
2018/03/05
1.2K0
MySQL配置主从复制
参考如下几篇博客:1:https://stackoverflow.com/questions/2995054/access-denied-for-user-rootlocalhost-using-passwordno
用户5927264
2019/08/01
1.1K0
MySQL配置主从复制
13.1 设置更改root密码
设置更改root密码目录概要 /usr/local/mysql/bin/mysql -uroot 更改环境变量PATH,增加mysql绝对路径 mysqladmin -uroot password '123456' mysql -uroot -p123456 密码重置 vi /etc/my.cnf//增加skip-grant 重启mysql服务 /etc/init.d/mysqld restart mysql -uroot use mysql; update user set password=passwo
运维小白
2018/02/06
3.6K0
MySQL重设密码_mysql重置密码命令
因为在重新设置MySQL的root密码的期间,MySQL数据库完全出于没有密码保护的
全栈程序员站长
2022/11/03
6.8K0
MySQL/MariaDB安装
(1)ERROR 1045 (28000): Access denied for user ‘root’@‘node1’ (using password: YES)
程裕强
2019/05/27
1.1K0
mysql忘记root密码解决方法
2.使用 mysqld –skip-grant-tables 命令启动mysql数据库
老高的技术博客
2022/12/27
7790
主从数据库案例详解
使用鲲鹏架构服务器(Linux)进行下述实验。操作系统为CentOS 7.6 64bit with ARM。本实验购买了华为云的弹性公网IP,IP为116.63.38.164(mysql1外网地址)和116.63.34.78(mysq2外网地址),可以使用远程连接工具访问此虚拟机。若在实训平台中进行此实验,不需要公网IP。
Weiyang
2020/06/15
1.3K0
Linux 环境下 MySQL 5.7 root密码忘记-解决方法
输入密码后提示:ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)
zinyan.com
2022/12/07
1.8K0
MySQL5.7.24 忘记root密码重设方法
在Linux下安装了MySQL5.7.24,重新设置密码的时候竟然忘记root密码了,没办法,只能重新搞一下,亲测可用。
星哥玩云
2022/08/17
8200
MySQL5.7.24 忘记root密码重设方法
在Linux环境下mysql的root密码忘记解决方法
方法一: 1.首先确认服务器出于安全的状态,也就是没有人能够任意地连接MySQL数据库。 因为在重新设置MySQL的root密码的期间,MySQL数据库完全出于没有密码保护的 状态下,其他的用户也可以任意地登录和修改MySQL的信息。可以采用将MySQL对外的端口封闭,并且停止Apache以及所有的用户进程的方法实现服务器的准安全状态。最安全的状态是到服务器的Console上面操作,并且拔掉网线。 2.修改MySQL的登录设置:  # vi /etc/my.cnf  在[mysqld]的段中加上一句:ski
joshua317
2018/04/09
1.3K0
相关推荐
MySQL root密码忘记,原来还有更优雅的解法!
更多 >
交个朋友
加入腾讯云官网粉丝站
双11活动抢先看 更有社群专属礼券掉落
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档