mysql数据库中修改用户密码

时间:2023-01-19 13:02:25

方法一:
登录mysql
mysql -u root -p
如果没有设置软连接,可以进入mysql安装目录
./mysql -u root -p
(使用whereis mysql命令查看mysql的安装路径)
然后输入root密码进入mysql

mysql>use mysql;
mysql> UPDATE user SET password=PASSWORD("new password") WHERE user='username';
mysql> FLUSH PRIVILEGES;
mysql> quit;

方法二:

mysqladmin -u root "old password" "new password"

方法三:

alter user 'root'@'localhost' identified by 'root';
FLUSH PRIVILEGES;