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?

  • Does your terminal prompt have a $ or a #? (I ask because normal users have $ in the prompt, but root has #) – Nick Weinberg Jul 13 '16 at 14:29
  • 2
    @NickWeinberg I think the issue here is the database root password not the system root password – steeldriver Jul 13 '16 at 14:30
  • @steeldriver Ahh, ok. I was confused because of the "sudo apt-get" command and "not being asked to input the password for root". But I think you're right – Nick Weinberg Jul 13 '16 at 14:31
  • @DavidFoerster I was trying to login as root in mariadb (not root in linux) by "mysql -u root -p" – user6133116 Jul 14 '16 at 1:00
17

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
  • 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 1: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
4

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.