Mysql5.5、5.6密码修改
mysqladmin -u root -p password 新密码
或者
mysql.user表中有password这一行
USE mysql;
SELECT * FROM USER;
UPDATE USER SET PASSWORD=PASSWORD('你的密码') WHERE USER='root';
或者
GRANT SELECT ON test.employee TO 'test'@'localhost' IDENTIFIED BY '123456';
GRANT DELETE ON test.employee TO 'test'@'localhost' IDENTIFIED BY '123456';
或者
这种方式需要先用root命令登入mysql,然后执行:
SET PASSWORD FOR root=PASSWORD('123456');
最后刷新权限
flush privileges;
Mysql5.7密码修改
5.7开始mysql.user表已经没有password字段了
mysqladmin -u root -p password 新密码
或者
update mysql.user set authentication_string=password('root') where user='root';
或者
alter user 'root'@'localhost' identified by '123456';
或者
set password for 'root'@'localhost'=password('123456');
或者
GRANT SELECT ON test.employee TO 'test'@'localhost' IDENTIFIED BY '123456';
最后刷新权限
flush privileges;
Mysql8.0密码修改
和5.7差别不大
mysqladmin -u root -p password 新密码
或者
alter user 'root'@'localhost' identified by '123456';
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '123456';
最后刷新权限
flush privileges;