14

I just had a fresh install on my pc the Ubuntu 16.04 LTS. When I tried to install MariaDB by typing:

sudo apt-get install mariadb-server

The installation went smoothly but during the process I was not prompted to input the password for the mysql root account. After the installation I was unable to log into MariaDB (mysql -u root -p) and it showed the error message:

ERROR 1698 Access denied for user 'root'

Everything was a fresh install. The entries in /etc/apt/sources.list were checked and all major components were enabled properly.

What seems to be the problem?

David Foerster
  • 36,900
  • 56
  • 98
  • 152

2 Answers2

18

Mariadb package doesn't offer a configuration wizard during installation on Ubuntu 16.04.

Use the below command to have a mysql shell

sudo mysql -uroot
edwinksl
  • 24,149
  • I tried it and it worked. Thanks. But I remember earlier when I installed mariadb I was prompted to set the root password. Since when was it changed? – user6133116 Jul 14 '16 at 01:04
  • @user6133116: That contradicts the statement in your question. Which one is it. Could you please clarify? – David Foerster Jul 14 '16 at 12:30
  • @DavidFoerster I'm sorry, but I really don't see any contradiction. I think you might not have got the idea of my question. – user6133116 Jul 14 '16 at 12:34
  • “during the process [of the installation] I was not prompted to input the password for the mysql root account” (taken from your question, highlight by me) vs. “when I installed mariadb I was prompted to set the root password” (taken from your comment) – David Foerster Jul 14 '16 at 12:46
  • @DavidFoerster "But I remember EARLIER when I installed mariadb I was prompted to set the root password. Since when was it changed?" Please pay attention to the word 'earlier' which I meant "some time ago, not this time". I was prompted to set the password for the database root account before, but not this time during this fresh install, hence the question posted in here. – user6133116 Jul 14 '16 at 14:23
  • It could also be some confusion made by my usage of the English language, as I'm not an English native speaker. If that's the case, I'm sorry. – user6133116 Jul 14 '16 at 14:25
  • Ah, that's exactly the type of clarification that I was looking for. I suspected this specific contextual meaning of “earlier” but didn't want to jump to conclusions. Sometimes people insert or omit a “not” by accident. – David Foerster Jul 14 '16 at 19:42
  • Worked for MariaDB version 10.0.25 on Ubuntu 15.10. – soufrk Sep 06 '16 at 07:48
  • This doesn't work for MariaDB 10.3.22 on Ubuntu 20.04. – Matthew Setter Oct 20 '20 at 07:08
4

Try sudo mysql -u root. You should be able to login this way.