windows中 mysql修改密码

一 在已知root用户名和密码的情况下

1.修改

C:\Windows\system32>mysql -uroot -p
Enter password: ********
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 15
Server version: 5.7.21 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> set password for 'root'@'localhost'=password('root');
Query OK, 0 rows affected, 1 warning (0.00 sec)

mysql> exit
Bye

2.新密码登录

C:\Windows\system32>mysql -uroot -p
Enter password: ****
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 17
Server version: 5.7.21 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>

二  在未知root用户名和密码的情况下

mysql数据备份还原与密码修改 - L杂货店 - 博客园

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
Windows修改 MySQL密码,可以按照以下步骤进行操作: 1. 打开命令提示符或 PowerShell,进入 MySQL 的安装目录的 bin 文件夹。例如,如果 MySQL 安装在 C 盘,可以输入以下命令进入 bin 文件夹: ``` cd C:\Program Files\MySQL\MySQL Server X.X\bin ``` (注意将 "X.X" 替换为你的 MySQL 版本号) 2. 停止 MySQL 服务。输入以下命令: ``` mysqladmin -u root -p shutdown ``` 系统会提示你输入 root 用户的密码。如果你没有设置密码,直接按回车键即可。 3. 启动 MySQL 服务,并跳过权限检查。输入以下命令: ``` mysqld --skip-grant-tables ``` 这将以跳过权限检查的方式启动 MySQL 服务。 4. 打开另一个命令提示符或 PowerShell 窗口,进入 MySQL 的安装目录的 bin 文件夹,以 root 用户身份登录 MySQL。输入以下命令: ``` mysql -u root ``` 5. 在 MySQL 提示符下,执行以下 SQL 语句来修改密码: ``` ALTER USER 'root'@'localhost' IDENTIFIED BY '新密码'; ``` 将 '新密码' 替换为你要设置的新密码。 6. 退出 MySQL,重新启动 MySQL 服务。在 MySQL 提示符下,输入以下命令: ``` exit ``` 然后在新的命令提示符或 PowerShell 窗口,输入以下命令启动 MySQL 服务: ``` mysqladmin -u root -p shutdown ``` 系统会提示你输入 root 用户的密码。这次要输入你刚才设置的新密码。 7. 启动 MySQL 服务。输入以下命令: ``` net start mysql ``` 这样,你就成功地在 Windows修改MySQL密码。请确保在执行这些步骤时按照顺序逐步操作,并根据自己的实际情况进行相应的替换和调整。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值