Linux下修改Mysql密码
Linux下修改Mysql登录密码
1.在/etc/my.cnf [mysqld]下添加skip-grant-table,保存退出
2.重启mysql服务
systemctl stop mysqld.service
systemctl start mysqld.service
3.免密登录
mysql -uroot
敲回车进入
mysql> flush privileges
4.修改密码
alter user 'root'@'%' identified with mysql_native_password by 'Mysql123.'
Mysql8.0修改密码,密码的复杂度有要求,密码应包含大小写字母、数字,特殊符号
5.删除/etc/my.cnf中的skip-grant-table,重启服务
拓展
创建可以远程连接的用户
mysql> create user 'fk'@'%' identified by 'Fk123.';
mysql> grant allon *.* to 'fk'@'%' with grant option;
mysql> flush privileges;