1

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

1 Answer 1

3

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.