第一种方法
将root的密码改为djg345
# mysqladmin -uroot -p123123 password djg345
以下方法需在mysql>提示符下操作
第二种方法 更改user01密码为user01pwd
mysql> SET PASSWORD FOR user01=PASSWORD("user01pwd");
mysql> show grants for test;
+-----------------------------------------------------------------------------------------------------
---------------------------+
| Grants for test@%
|
+-----------------------------------------------------------------------------------------------------
---------------------------+
| GRANT ALL PRIVILEGES ON *.* TO 'test'@'%' IDENTIFIED BY PASSWORD
'*6BB4837EB74329105EE4568DDA7DC67ED2CA2AD9' WITH GRANT OPTION |
+-----------------------------------------------------------------------------------------------------
---------------------------+
1 row in set (0.00 sec)
1.修改test用户密码为147258
[mysql@master ~]$ mysqladmin -u test -p password 147258
Enter password: --这里输入的是原密码
[mysql@master ~]$
[mysql@master ~]$ mysql -utest -p147258
2.第2种方式:
--修改test用户密码为999999
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> UPDATE user SET password=PASSWORD('999999') WHERE user='test';
Query OK, 2 rows affected (0.00 sec)
Rows matched: 2 Changed: 2 Warnings: 0
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
mysql>