修改用户密码分三种方法:
第一种:set password for 用户名字@ip = password('密码');
set password for [email protected]= password('123456');
第二种:mysqladmin -u用户 -p旧密码 password 新密码;
mysqladmin -uroot -p123456 password;
第三种:update mysql.user set authentication_string=password('密码') where user='用户' and host='ip';
update mysql.user set authentication_string=password('123456') where user='root' and host='192.168.0.111';
忘记密码:
- 第一步:修改配置文件my.cnf (默认在/etc/my.cnf),在[mysqld]下面加上 skip-grant-tables (跳过权限的意思)
- 第二步:重启mysql服务
- 第三步:mysql -uroot -p 无需密码登录进入
- 第四步:修改密码