superman 的好处是可以为所欲为,不仅可以修改自己的密码,还能给别人授权,修改别人的密码。
1、修改自己 的密码
首先要先登录mysql,
然后: mysqladmin -u root -p password "123445"
还有一种方法: 通过mysql.user
use mysql;
update user set authentication_string=password("123456"') where user='root';
但是上面不起作用。
use mysql;
update user set authentication_string="123456" where user='root';
flush privileges;
这下好,直接导致原密码不管用,新设置的密码:123456 也不管用
靠,开始用绝招。
mysqld --shared-memory --skip-grant-tables(我已经设置了环境变量,所以不用 cd .......)
此时会hang住,重新打开cmd
mysql -u root -p
直接回车,不用输入密码
妈呀,终于进来了。
赶紧改个密码
update mysql.user set authentication_string="" where user='root';
flush privileges;
直接给它来了个无密码
终端推出 exit;
服务端直接关闭(还不知道其他方法)
重新登录
以管理员身份打开cmd 然后
net start mysql
mysql -h 127.0.0.1 -u root -p
直接回车,进入了,我的天,给自己烦死了。
mysql 8.0.16 版本
mysqladmin -u root -p password "123456" 这种方法可以
alter user 'root'@'localhost' identified by "123456" 这种方法也可以
但是
set password = password("123456")
以及
use mysql
update user set authentication_string=password("123456") where user="root"
这种两种方法总是报语法错误,感觉好像和password 有关。(有没有人指点下?)
未完待续