mysql 8.0 root修改密码

查看mysql8.0安装的默认账号密码

sudo cat /etc/mysql/debian.cnf

文件内容如下

[client]
host     = localhost
user     = debian-sys-maint
password = voWlZ5cZNV266m8
socket   = /var/run/mysqld/mysqld.sock
[mysql_upgrade]
host     = localhost
user     = debian-sys-maint
password = voWlZ5cZNV26k6m8
socket   = /var/run/mysqld/mysqld.sock

使用默认账号密码登录mysql

mysql -udebian-sys-maint -pvoWlZ5cZNV26k6m8

查看账号信息

use mysql;
select Host,User,authentication_string from user;

修改root密码

update user set authentication_string=‘‘ where user=‘root‘;
ALTER user ‘root‘@‘localhost‘ IDENTIFIED WITH mysql_native_password BY ‘root‘;
flush privileges;

成功后,使用root登录

mysql -uroot -proot

mysql 8.0 root修改密码

上一篇:SQL-给某一字段的最右加上固定字符


下一篇:window10安装不同版本的mysql(5.7和8.0.25)