I know this question is old, but I had the same problem, and the steps described below solved my problem:
on the Linux terminal, run the command below to set a new password for the root user, skip this step if the root password is already set.
mysqladmin --user=root password "newpassword"
Log in to MySQL
mysql -uroot -p
Enter root password
Run the following query on the MariaDB console
MariaDB [(none)]> select host,user,password from mysql.user;
You may notice that some entries with the values โโof the 'user' column are '' (empty), delete these entries using the following query
MariaDB [(none)]> delete from mysql.user where user=''; MariaDB [(none)]> flush privileges; Query OK, 2 rows affected (0.00 sec) MariaDB [(none)]> exit Bye
You will not be able to enter MySQL without a password after performing the above steps.
NCode source share