Access denied for user 'root'@'localhost'

I am getting this error with adminer.php and phpmyadmin won't work either. I am able to run SQL commands in terminal after typing 'sudo mysql'. I have a user table with root as a username but there is no password field.

If anyone can help me to get this to work it would be great.

3 Answers 3


This solved my problem - can't login as mysql user root from normal user account in ubuntu 16.04

I'm using Ubuntu 18.04 and so these instructions work for me.


write this this command in your terminal with root user

getsebool -a | grep http

and look to httpd_read_user_content if it's off then you have to make it on by this command

setsebool -P httpd_read_user_content on 

then restart your apache server and try to access to adminer and phpmyadmin

  • 2
    The command getsebool is not installed on Ubuntu by default. In the last line, what do you mean by "adminer".
    – vanadium
    Sep 9, 2018 at 12:40
  • @vanadium adminer is a database management tool like phpmyadmin you can see more informations here adminer.org Sep 9, 2018 at 12:58

In newer versions of MariaDB/MySQL the default root user authentication method on Linux is unix socket. In other words, only the root user itself can login to the MySQL root user account (and no password is needed).

As unix socket authentication is the most secure way to authenticate, IMO the best way to go is to create a new root-like user (that does require a password) for use with Adminer (and/or other DB interfaces that require a user is authenticated via password).

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .