当前位置:网站首页>修改MySQL密码的四种方法(适合初学者)
修改MySQL密码的四种方法(适合初学者)
2022-07-28 01:26:00 【@每天都要敲代码】
作者简介:大家好我是@每天都要敲代码,一位材料转码农的选手,希望一起努力,一起进步!
个人主页:@每天都要敲代码的个人主页
推荐一款模拟面试、刷题神器,从基础到大厂面试题点击跳转刷题网站进行注册学习作为初学者,对于MySQL密码的修改,目前我已知的有四种方法:前三种是在知道密码的情况下修改,因为需要我们先登录;最后一种适合忘记密码的情况下进行修改!
目录
方法1:用set password命令
(1)首先要先登录MySQL:

(2)修改密码格式为:
set password for 用户名@localhost = password('新密码'); 一定不要忘记最后面的分号,例如:我们把密码改成成123:
set password for [email protected] = password('123');出现以下界面说明修改成功:

方法2:用mysqladmin
利用mysqladmin,我们不需要先登录,但是需要直到原来的密码;我们可以直接修改,修改密码格式为:
mysqladmin -u用户名 -p旧密码 password 新密码,注意,password前面没有 - ,例如:我们再把密码改成123456:
mysqladmin -uroot -p123 password 123456出现以下界面说明修改成功

方法3:用update直接编辑user表
(1)首先要先登录MySQL
(2)然后依次输入:
use mysql # 连接权限数据库
update user set password=password('521') where user='root' and host='localhost'; # 改密码
flush privileges; # 刷新权限出现以下界面说明修改成功:

方法4:忘记密码处理方式
1. 关闭正在运行的MySQL服务。
win+r输入:services.msc回车,找到MySQL,手动关闭MySQL服务
2. 打开DOS窗口,利用cd命令转到mysql的bin目录:建议直接找到mysql的bin目录下输入cmd回车
3. 输入mysqld --skip-grant-tables 回车。--skip-grant-tables 的意思是启动MySQL服务的时候跳过权限表认证。
4. 再开一个DOS窗口(刚才那个DOS窗口已经不能动了),转到mysql的bin目录。
5. 输入mysql回车,如果上面修改成功,将直接出现 mysql> 这样的提示符。
6. 连接权限数据库: use mysql
6. 改密码:update user set password=password("123") where user="root";
7. 刷新权限(必须步骤):flush privileges; (不要忘记分号)
8.exit或者ctrl+c退出,进行重新登陆
结束语
今天的分享就到这里啦!快快通过下方链接注册加入刷题大军吧!各种大厂面试真题在等你哦!
刷题神器,从基础到大厂面试题点击跳转刷题网站

边栏推荐
- 程序里随处可见的interface,真的有用吗?真的用对了吗?
- Unity saves pictures to albums and rights management
- 作业7.27 IO进程
- When iPhone copies photos to the computer, the device connection often fails and the transmission is interrupted. Here's the way
- [机缘参悟-53]:阳谋立身,阴谋防身
- 并发编程的三大核心问题(荣耀典藏版)
- Sqlserver problem solving: replication components are not installed on this server. Please run SQL Server Setup again and select the option to install replication components
- Explore flex basis
- Leetcode hot topic Hot 100 - > 3. longest substring without repeated characters
- 关于Sqli-labs单引号不报错的问题
猜你喜欢

How MySQL uses indexes (glory Collection Edition)

Deep Residual Learning for Image Recognition浅读与实现

Smart contract security -- selfdestroy attack

【愚公系列】2022年07月 Tabby集成终端的使用

APP如何上架App Store?

Soft test - database (2) relational model

Wechat campus bathroom reservation applet graduation design finished product (2) applet function

Canonical Address
![[Yugong series] July 2022 go teaching course 019 - for circular structure](/img/40/b4e673de0462c3dd6ca8b8fb513914.png)
[Yugong series] July 2022 go teaching course 019 - for circular structure

Ceresdao: the world's first decentralized digital asset management protocol based on Dao enabled Web3.0
随机推荐
Get the difference data of two sets
Mysql Explain 详解(荣耀典藏版)
feign调用get和post记录
Flask1.1.4 werkzeug1.0.1 source code analysis: Blueprint
【软件测试】—— 自动化测试之unittest框架
Lombok prompts variable log error when using JUnit test in idea
Leetcode judge whether palindrome number
借助Elephant Swap打造的ePLATO,背后的高溢价解析
Three core issues of concurrent programming (glory Collection Edition)
Digital empowerment and innovation in the future: hese eredi appears at the 5th Digital China Construction Summit
Xiaomi website homepage big module - small module + navigation (floating case)
[Yugong series] use of tabby integrated terminal in July 2022
pytorch优化器设置
组原必备知识点
[Star Project] small hat aircraft War (V)
实际工作中,我是如何使用 Postman 做接口测试?
QT implementation disable shortcut key
How MySQL uses indexes (glory Collection Edition)
How to put app on the app store?
Flume (5 demos easy to get started)
