Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

MySQL: cannot connect from mysql client nor PHP

10 views
Skip to first unread message

Jivanmukta

unread,
Feb 6, 2017, 2:57:32 PM2/6/17
to
Sorry for my English.

I programmed my first application in PHP+MySQL. It was working fine.
Since a few days I have error connecting to database: Message:
mysqli::real_connect(): (HY000/1698): Access denied for user
'root'@'localhost'.
I tried: "mysql -u root -p -h localhost" and I have "Access denied for
user root@localhost'.
Command "sudo mysql -u root -p -h localhost" works fine.
In mysql log I have only access denied.
Reinstalling mysql doesn't help. mysql_upgrade doesn't help, either.

$ mysql --version
mysql Ver 14.14 Distrib 5.7.17, for Linux (i686) using EditLine wrapper

Here you have my privileges:
mysql> show grants for 'root'@'localhost';
+---------------------------------------------------------------------+
| Grants for root@localhost |
+---------------------------------------------------------------------+
| GRANT ALL PRIVILEGES ON *.* TO 'root'@'localhost' WITH GRANT OPTION |
| GRANT PROXY ON ''@'' TO 'root'@'localhost' WITH GRANT OPTION |
+---------------------------------------------------------------------+
2 rows in set (0,00 sec)

Please help. I would like to avoid reinstalling Ubuntu.
$ uname -a
Linux pecet 4.4.0-38-generic #57-Ubuntu SMP Tue Sep 6 15:41:41 UTC 2016
i686 i686 i686 GNU/Linux

lu...@invalid.lan

unread,
Feb 19, 2017, 11:10:02 AM2/19/17
to
Does the output of this command give the same password on all lines?
SELECT Host, User, Password
FROM mysql.user
WHERE user='root';

Do you have a password installed for the user 'root'?
If not, try to set a password:
ALTER USER 'root'@'localhost' IDENTIFIED BY 'MyNewPass';
(see: https://dev.mysql.com/doc/refman/5.7/en/resetting-permissions.html )
0 new messages