使用 MySQL 根密码访问被拒绝

使用 MySQL 根密码访问被拒绝

我在 Ubuntu 22.04 上安装 MySQL 时出错。

当我这样做su - mysql -u rootsu - mysql -u root我得到Access denied for user 'root'@'localhost'如何才能让它再次工作?

[1]+  Stopped                 mysql
root@ubuntu-instance1:~# sudo mysql -u root

Welcome to the MySQL monitor.  Commands end with ; or \g. Your MySQL connection id is 16 Server version: 8.0.31-0ubuntu0.22.04.1 (Ubuntu)

mysql>
update user set plugin='' where User='root';
flush privileges;

Database changed
mysql> 
Query OK, 1 row affected (0.00 sec)
Rows matched: 1  Changed: 1  Warnings: 0**

相关内容