sudo mysql
可直接登入 mysql.
Ubuntu 系统,通过命令 sudo apt install mysql-server
安装了 mysql, 在 Bash 界面可以免密码登录,原因是 root
密码为空,修改 root
密码,网上找到的方法:
1 | UPDATE mysql.user SET authentication_string = PASSWORD('123456'), password_expired = 'N' WHERE User = 'root' AND Host = 'localhost'; |
但是,任然可以免密码登录:

配置了 phpmyadmin, 登录则出现的错误是:
1 | 1698 - Access denied for user 'root'@'localhost' |
继续搜, 看到这个 https://blog.csdn.net/david_sheep/article/details/82698709,自己试了下,果真如此

按如下修改密码:
1 | UPDATE mysql.user SET authentication_string = PASSWORD('123456'), password_expired = 'N', plugin = 'mysql_native_password' WHERE User = 'root' AND Host = 'localhost'; |