MySQL数据库密码篇

来源:互联网 发布:网络教育统考成绩 编辑:程序博客网 时间:2024/06/03 23:24

        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服务

 

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

2 0
原创粉丝点击