记得密码的情况修改密码
[root@VM-16-7-centos redis]# mysqladmin -uroot -p'旧密码' password
'新密码'
忘记密码修改密码
1.打开mysql配置文件末尾添加skip-grant-tables
vim /etc/my.cnf
[mysqld]
skip-grant-tables
2.重启数据库
systemctl restart mysqld
3.登录数据库
[root@VM-16-7-centos redis]# mysql
4.修改密码
update mysql.user set password=password("密码") where user='用户名' and host="这里填host一般为localhost或者%";
举例
UPDATE mysql.user SET authentication_string=PASSWORD('cdWHyxgs@33*!..') WHERE User='root' AND Host='localhost';
5.刷新
flush privileges;
6.打开配置文件my.cnf注释skip-grant-tables重启