Installed MySQL server but mysql command does not ask for password in the shell

Solution 1:

The reason is that MySQL uses socket authentication option by default for the root user.

If you want to disable it, you need to change Authentication plugin for the root account from "Socket authentication" to "Native MySQL authentication".

Solution 2:

Probably socket authentication where MySQL basically authenticates you if the username calling the mysql binary matches a known username to MySQL.

The server-side auth_socket authentication plugin authenticates clients that connect from the local host through the Unix socket file. The plugin uses the SO_PEERCRED socket option to obtain information about the user running the client program. Thus, the plugin can be used only on systems that support the SO_PEERCRED option, such as Linux.