Mysql – MariaDB ignores root password completely

mariadbMySQL

I just installed MariaDB (mysqld) on a fresh Ubuntu downloaded yesterday.
Then I ran the script

/usr/bin/mysql_secure_installation

and set new root password and disabled passwordless login. However this didn't work so I tried form the command line:

root@www:~# mysqladmin password whatever
root@www:~# mysql -uroot 
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 35
Server version: 10.0.24-MariaDB-7 Ubuntu 16.04

Copyright (c) 2000, 2016, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [(none)]> \q
Bye
root@www:~# 
root@www:~# mysql -uroot -plkasjfdklajsfd
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 38
Server version: 10.0.24-MariaDB-7 Ubuntu 16.04

Copyright (c) 2000, 2016, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [(none)]> use mysql
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
MariaDB [mysql]> select Host , User, Password from user;
+-----------+------+-------------------------------------------+
| Host      | User | Password                                  |
+-----------+------+-------------------------------------------+
| localhost | root | *90837F291B744BBE86DF95A37D2B2524185DBBF5 |
+-----------+------+-------------------------------------------+
1 row in set (0.00 sec)

Why does mysql ignores my password change instructions and worse , it allows passwordless login as root?

Best Answer

Some Debian based distributions have started to use the UNIX socket authentication plugin for the root user. This means that the operating system account is linked to the database root account and you can only access the database if you have superuser privileges. To my knowledge, this is done to make the initial installation more secure.

To verify that it is indeed the UNIX socket authentication plugin that is causing this, you can log in as another user and try to connect to the database with mysql -uroot. If it fails, you've just confirmed that the database uses the UNIX socket authentication plugin.

By default, the mysql client will use a local UNIX domain socket to connect to a server. To use a network connection, give the loopback address as the hostname with -h 127.0.0.1. This should allow you to connect as the root user with an explicit password.

Related Topic