MySQL数据库密码篇

        MySQL数据库忘记密码了怎么办?重装MySQL?NO,那样有点小复杂(如果你想拿我写的MySQL重装篇练练手还是可以的,学习就得多折腾,哈哈……),最重要的是那样你之前的数据就都没有了哦。今天我为大家带来一个简便的方法来重设密码。以下是我在Mysql5.1版本下的测试,按照这个步骤走一遍就OK啦。

 

1.打开数据库安转目录下的配置文件(*.ini文件)

[mysqld]段中加上一句:skip-grant-tables          #跳过权限验证

 

2.重启mysql服务

 

3.直接mysql登录(前提是已经配置了path路径,否则要进入bin目录才行)

例如:

C:\WINDOWS\system32>mysql

回车后显示如下:

Welcome to theMySQL monitor.  Commands end with ; or\g.

Your MySQLconnection id is 1

Serverversion: 5.5.43 MySQL Community Server (GPL)

 

Copyright (c)2000, 2015, Oracle and/or its affiliates. All rights reserved.

 

Oracle is aregistered 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>

 

 

4.修改密码

mysql> USEmysql ;           #打开mysql数据库

Databasechanged

mysql>UPDATE user SET Password = password ( ‘new-password’ ) WHERE User = ‘root’ ;           #修改用户数据表

Query OK, 0rows affected (0.00 sec)

Rows matched:2 Changed: 0 Warnings: 0

 mysql> flush privileges ;         #刷新权限

Query OK, 0rows affected (0.01 sec)

mysql> quit         #退出

Bye

 

5.将配置文件改回        #不要忘了哦

 

6.重启mysql服务

 

到此,密码设置完毕!!!写的还算凑合,希望对小伙伴们有帮助哦。

  • 3
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值