当前位置:Gxlcms > 数据库问题 > MySQL改密

MySQL改密

时间:2021-07-01 10:21:17 帮助过:3人阅读

一、未进入之前:

1、grep password /var/log/mysqld.log   得出默认密码
2、更改密码
    mysqladmin -uroot -p‘d-tlbwIgP3e2‘ password  "QianFeng@123"
                                默认密码/老密码                                 新密码
3、登录数据库
    mysql -uroot -p‘QianFeng@123‘

二、在数据库里:

方法一
1、set password for root@localhost = password(‘你要改的密码‘);
方法二
2、mysql> select user,host,authentication_string from mysql.user;
+---------------+-----------+-------------------------------------------+
| user          | host      | authentication_string                     |
+---------------+-----------+-------------------------------------------+
| root          | localhost | *1288B346EB8ABFFC6F6F1B79C437AF124FFE05C7 |
| mysql.session | localhost | *THISISNOTAVALIDPASSWORDTHATCANBEUSEDHERE |
| mysql.sys     | localhost | *THISISNOTAVALIDPASSWORDTHATCANBEUSEDHERE |
+---------------+-----------+-------------------------------------------+
rows in set (0.00 sec)

mysql> update mysql.user set
    -> authentication_string=password(‘TianYun@52‘)
    -> where user=‘root‘ and host=‘localhost‘;
Query OK, 1 row affected, 1 warning (0.00 sec)
Rows matched: 1  Changed: 1  Warnings: 1

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

三、取消密码复杂度

编辑 /etc/my.cnf 配置?件, 在 [mysqld] 配置块?中添加
plugin-load=validate_password.so
validate-password=OFF

MySQL改密

标签:upd   war   user   from   log   local   tca   not   query   

人气教程排行