0

When I try to deploy my app I get this error

Mysql2::Error: Access denied for user 'root'@'localhost' (using password: YES)

when I try to log in to sql as root it works

$ sudo mysql -u root -p

but when I try to log in as a normal user I get the error

$ mysql -u root -p
Enter password: 
ERROR 1698 (28000): Access denied for user 'root'@'localhost'

Why mysql root password works for system root but doesn't work for the systems regular user?

solution

answer to this question has helped to some extent

https://serverfault.com/questions/254629/unable-to-install-mysql-server-in-ubuntu

also I had to remove offending file from apparmor

Setting up mysql-server-5.7 (5.7.12-0ubuntu1) ... AppArmor parser error for /etc/apparmor.d/usr.sbin.mysqld in /etc/apparmor.d/usr.sbin.mysqld at line 9: Could not open 'abstractions/mysql'

So I had to run this command to get rid of the error. After that Mysql got instaled cleanly and I can log in as regular user.

rm /etc/apparmor.d/usr.sbin.mysqld

Community
  • 1
  • 1
ruby_object
  • 1,229
  • 1
  • 12
  • 30
  • **Solution:** Reset root password: [Post by Christian Mark](http://stackoverflow.com/a/16556534/6214696) – Alisson Linneker Jun 15 '16 at 10:20
  • nothing I tried worked, when I tried to purge mysql following this link http://askubuntu.com/questions/640899/uninstall-mysql-completely it seemed I was able to set new password when installing mysql from scratch, but nuo I'm stuck at apparmor problems AppArmor parser error for /etc/apparmor.d/usr.sbin.mysqld in /etc/apparmor.d/usr.sbin.mysqld at line 9: Could not open 'abstractions/mysql' Job for mysql.service failed because the control process exited with error code. See "systemctl status mysql.service" and "journalctl -xe" for details. – ruby_object Jun 15 '16 at 10:47
  • Are you using MariaDB? – Solarflare Jun 15 '16 at 11:18
  • @Solitaire - no, it's mysql – ruby_object Jun 15 '16 at 11:42
  • Check `select plugin from user where User='root';` Can you login as non-root-mysql-user from non-root? – Solarflare Jun 15 '16 at 14:40
  • do self-answers below, don't put the solution you found in your question block. All that reads as is confusion and it wastes people's time wondering, wait, did he fix it, huh – Drew Jun 15 '16 at 15:04
  • I consider it fixed. As I said I tried to wipe out mysql clean form the system and installed it again. I was following a tutorial on digital ocean that was meant for Ubuntu 14.04 while I was using 16.04. @Solitaire I did not have not root mysql user. at Drew I guess people will keep bumping into problems like this so it would be worth to rewrite my post to make it easier to fix for other people. I just don't know how to do it. – ruby_object Jun 15 '16 at 16:14

0 Answers0