mysql更改密码

1:首先是mysql服务启动着

2:打开DOS如下,win7系统

Microsoft Windows [版本 6.1.7601]
版权所有 (c) 2009 Microsoft Corporation。保留所有权利。

C:UsersAdministrator>cd C:Program Files (x86)MySQLMySQL Server 7.0in  ------进入到数据库安装目录的bin目录下

C:Program Files (x86)MySQLMySQL Server 7.0in>mysql -uroot -p  -------------打开mysql
Enter password: ****-------自动提示输入密码
Welcome to the MySQL monitor.  Commands end with ; or g.
Your MySQL connection id is 2
Server version: 5.1.39-ndb-7.0.9-cluster-gpl MySQL Cluster Server (GPL)

Type 'help;' or 'h' for help. Type 'c' to clear the current input statement. ---------成功登陆

mysql> set password for root@localhost = password('test');-------修改密码
Query OK, 0 rows affected (0.00 sec)

mysql> exit----退出
Bye

C:Program Files (x86)MySQLMySQL Server 7.0in>mysql -uroot -p-----再次登录
Enter password: ****-----输入原密码
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: Y----------------原密码报错登不上
ES)

C:Program Files (x86)MySQLMySQL Server 7.0in>mysql -uroot -p-------再次尝试登录
Enter password: ****------输入新密码
Welcome to the MySQL monitor.  Commands end with ; or g.
Your MySQL connection id is 4
Server version: 5.1.39-ndb-7.0.9-cluster-gpl MySQL Cluster Server (GPL)

Type 'help;' or 'h' for help. Type 'c' to clear the current input statement.

mysql>-------成功登陆,密码被修改了

原文地址:https://www.cnblogs.com/xueershewang/p/6877774.html