I figured out why it happened. Please check file /etc/mysql/mariadb.conf.d/mysqld.cnf:
#
# * Unix socket authentication plugin
#
# Needed so the root database user can authenticate without a password but
# only when running as the unix root user.
#
# Also available for other users if required.
# See https://mariadb.com/kb/en/unix_socket-authentication-plugin/
plugin-load-add = auth_socket.so
And:
MariaDB [mysql]> select User,Host,plugin from user where User='root';
+------+-----------+-------------+
| User | Host | plugin |
+------+-----------+-------------+
| root | localhost | unix_socket |
| root | u15 | unix_socket |
| root | 127.0.0.1 | unix_socket |
| root | ::1 | unix_socket |
+------+-----------+-------------+
If remove 'unix_socket' in `mysql.plugin` column, root user must login with a password.