知道root密码的情况下:

1. 先登录mysql

[root@226] # mysql -uroot -p123456

Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 108631
Server version: 5.5.35-log MySQL Community Server (GPL)

Copyright (c) 2000, 2014, 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.

2. 使用mysql数据库

mysql> use mysql;
Database changed

3. update语句修改root用户的密码

mysql> UPDATE user SET password = password('654321') WHERE user = 'root';
Query OK, 5 rows affected (0.03 sec)
Rows matched: 5  Changed: 5  Warnings: 0

4. 刷新权限配置

mysql> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.07 sec)

---------------------------------------

如图:

---------------------------------------

密码修改完毕!

(转载本站原创文章请注明作者与出处Coding云--codingyun.com)

打赏
  • 微信
  • 支付宝

评论
来发评论吧~