MySQL修改root密码的4种方法(以windows为例)
方法【fāng fǎ】🥟1: 用【yòng】🍔SET PASSWORD命令【mìng lìng】
首先登录【lù】MySQL。
格式🗄:mysql> set password for 用【yòng】🍔户名@localhost = password('新密码【xīn mì mǎ】');
例子:mysql> set password for root@localhost = password('123');
方法【fāng fǎ】🥟2:用【yòng】🍔mysqladmin
格式🗄:mysqladmin -u用【yòng】🍔户名 -p旧密码【jiù mì mǎ】🐦 password 新密码【xīn mì mǎ】
例子:mysqladmin -uroot -p123456 password 123
方法【fāng fǎ】🥟3:用【yòng】🍔UPDATE直接编🙅辑user表【biǎo】
首先登录【lù】MySQL。
mysql> use mysql;
mysql> update user set password=password('123') where user='root' and host='localhost';
mysql> flush privileges;
方法【fāng fǎ】🥟4:在忘记root密码的【mì mǎ de】时候【shí hòu】🐟,可以🐾这样
以🐾windows为例📆:
1. 关闭正⛏在运行♏的MySQL服务。
2. 打开DOS窗口✉,转到♿mysql\bin目录【mù lù】🥔。
3. 输入🌷mysqld --skip-grant-tables 回车😐。--skip-grant-tables 的意思是启动🧚MySQL服务的🥜时候【shí hòu】🐟跳过权限表认【xiàn biǎo rèn】证。
4. 再开一【zài kāi yī】❕个【gè】DOS窗口✉(因为刚【yīn wéi gāng】才那个【gè】DOS窗口已🕹经不能动了【dòng le】😻),转到♿mysql\bin目录【mù lù】🥔。
5. 输入🌷mysql回车😐,如果成【rú guǒ chéng】😵功,将出现MySQL提示符【tí shì fú】 >。
6. 连接权【lián jiē quán】🎧限数据【xiàn shù jù】✈库: use mysql; 。
6. 改密码🔓:update user set password=password("123") where user="root";(别忘了最后加【zuì hòu jiā】分号) 。
7. 刷新权限(必须步骤):flush privileges; 。
8. 退出 quit。
9. 注销系✂统【tǒng】,再进入【zài jìn rù】,使用【yòng】🍔用【yòng】🍔户名root和刚才设置的新密码【xīn mì mǎ】123登录【lù】。
关键词:mysql,windows
阅读本文后您有什么感想? 已有 人给出评价!
- 1
- 44
- 2
- 2
- 22
- 1