天天看点

mysql之修改用户密码

文章目录

  • ​​首先root用户登陆-mysql -u root -p​​
  • ​​选择库-use mysql;​​
  • ​​修改指定用户的密码​​
  • ​​刷新权限后退出​​

首先root用户登陆-mysql -u root -p

[root@izwz91h49n3mj8r232gqwez usr]# mysql -u root -p
Enter password:      
[root@izwz91h49n3mj8r232gqwez usr]# mysql -u root -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 3284
Server version: 5.6.42-log 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>      

选择库-use mysql;

mysql> use mysql;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
mysql>      

修改指定用户的密码

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

刷新权限后退出

mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)

mysql> exit;