官方原文链接mysql set password
操作之前先查看自己MySql
的版本号对号入座。
mysql --version
5.7.6版本以上
连接
mysql -u root
修改密码
ALTER USER user IDENTIFIED BY 'new_password';
修改密码与授权远程
ALTER USER `'root'@'localhost'` IDENTIFIED BY 'new_password'
查询表信息
SELECT User, Host, HEX(authentication_string) FROM mysql.user;
5.7.6版本以下
连接
mysql -u root
修改密码
SET PASSWORD FOR user = PASSWORD('new_password');
修改密码与授权远程
SET PASSWORD FOR 'user'@'localhost' = PASSWORD('new_password');
查询表信息
SELECT User, Host, Password FROM mysql.user;
网友评论