美文网首页
Ubuntu安装MySQL 8.0.21更改默认用户密码

Ubuntu安装MySQL 8.0.21更改默认用户密码

作者: dragon海鸟 | 来源:发表于2020-08-05 00:43 被阅读0次
  • 查看初始密码
    初始密码存放在/etc/mysql/debian.cnf文件中
/etc/mysql$ sudo cat debian.cnf
# Automatically generated for Debian scripts. DO NOT TOUCH!
[client]
host     = localhost
user     = debian-sys-maint
password = OSozOdppag50NmbG
socket   = /var/run/mysqld/mysqld.sock
[mysql_upgrade]
host     = localhost
user     = debian-sys-maint
password = OSozOdppag50NmbG
socket   = /var/run/mysqld/mysqld.sock
  • 用初始账号密码登录
/etc/mysql$ mysql -u debian-sys-maint -p
Enter password: OSozOdppag50NmbG
  • 修改密码
    注意:老的语句已经不行了 update user set authentication_string=password(“newPassword”) where user=“root”;
mysql> use mysql;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
mysql> ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '123456';// 123456为新密码
Query OK, 0 rows affected (0.01 sec)

mysql> flush privileges;
Query OK, 0 rows affected (0.01 sec)

mysql> quit;
Bye
  • 重新登录
mysql -uroot -p

相关文章

网友评论

      本文标题:Ubuntu安装MySQL 8.0.21更改默认用户密码

      本文链接:https://www.haomeiwen.com/subject/dwngrktx.html