Mysql – Access denied for user ‘root’@’localhost’ (using password: NO) on ‘service thesql start’

MySQL

Environment

$ uname -a
Linux aurora 4.4.0-59-generic #80-Ubuntu SMP Fri Jan 6 17:47:47 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux

MySQL

$ mysqladmin --version
mysqladmin  Ver 8.42 Distrib 5.7.16, for Linux on x86_64

Clearly something is trying to log into my mysql server as root upon

service mysql start

but I don't know what it is.

The last line in /var/log/mysql/error.log related to starting the server is:

[Note] Access denied for user 'root'@'localhost' (using password: NO)

How do I figure the offending config file or server or application that is trying to log in as 'root'@'localhost' on startup? What other information can I provide to help to understand and resolve this issue?

Also, I am able to log in as 'root'@'localhost' if I do so explicitly. It's only the [Note] in the error log that is irritating me and that I want to debug.

In order to reduce the number of variables, I've also shutdown apache and deleted my crontab just in case that was part of the problem.

I am open to all suggestions.

Redirected from https://stackoverflow.com/questions/41601069/access-denied-for-user-rootlocalhost-using-password-no-on-service-mysql

Best Answer

I had similar problem.

https://stackoverflow.com/questions/38098505/mysql-works-with-sudo-but-without-not-ubuntu-16-04-mysql-5-7-12-0ubuntu1-1

And solved id following by:

https://askubuntu.com/questions/766334/cant-login-as-mysql-user-root-from-normal-user-account-in-ubuntu-16-04

sudo mysql -u root
DROP USER 'root'@'localhost';
CREATE USER 'root'@'%' IDENTIFIED BY '';
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%';
FLUSH PRIVILEGES;