mysql修改密码的方式常见的有以下四种:
1. 已知密码的情况下:
1.1 mysqladmin修改
mysqladmin -uroot -p1204 password 1234
1.2 set password
set password for root@localhost = password('2345');
1.3 update user (mysql5.7以后是setauthentication_string字段,之前是password)
mysql> use mysql;
mysql> UPDATE user SET plugin='mysql_native_password' WHERE User='root';
mysql> update user set authentication_string=password('123') where user='root' and host='localhost';
mysql> flush privileges;
mysql> exit;
ubuntu18需要在flush privileges前加
update user set plugin="mysql_native_password";


2.忘记密码的情况下:
sudo /etc/init.d/mysql stop
sudo mysqld_safe --user=mysql --skip-grant-tables --skip-networking &
mysql> use mysql;
mysql> update user set authentication_string=password('123') where user='root' and host='localhost';
mysql> flush privileges;
mysql> exit;
最后
以上就是激动小猫咪最近收集整理的关于mysql修改密码的全部内容,更多相关mysql修改密码内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复