问题原文
原帖链接 · Black · CC BY-SA 4.0
If I try to login to mysql with mysql -u root -p and enter the wrong password, then I get "access denied".
However, if I use sudo mysql -u root -p and enter the wrong mysql password, then I get access.
Version: mysql Ver 15.1 Distrib 10.3.25-MariaDB, for debian-linux-gnu (x86_64) using readline 5.2
已采纳解答
原帖链接 · codlord · CC BY-SA 4.0
It's likely due to the the root user using the unix_socket method of authentication. With this method a password it not used, only the operating system user matching the database user can login. So only the root OS user can login as the root database user. And although it's accepting a password on the command line it's being ignored.
See the MariaDB knowledgebase for more detailed info including (if you really want/need) how to change to password authentication.
If you do use mysql; followed by select user, plugin from user; you can see which authentication plugins are configured for which users.
摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。
