Re: cannot connect from mysql client nor PHP, only sudo
Date: Fri, 10 Feb 2017 20:57:48 +0100
Message-ID: <o7l5sg$79u$1_at_dont-email.me>
[Quoted] On 10.02.2017 11:04, Jivanmukta wrote:
> I programmed my first application in PHP+MySQL. It was working fine.
> Since a few days I have error connecting to database
[Quoted] If it worked until a few days ago: what has changed?
> (HY000/1698): Access denied for user 'root'_at_'localhost'.
> I tried: "mysql -u root -p -h localhost" and I have "Access denied for user
> root_at_localhost'
[Quoted] Did you ever set a password for root_at_localhost? MySQL ships by default with no password for that user, but some installation routines may ask the user to set a password.
Why are you using the root_at_localhost account for a PHP application anyway? This is a big security hole. You should create a specific user for that application and GRANT that user access only to those databases/tables that it needs to fulfill it's purpose.
> Command "sudo mysql -u root -p -h localhost" works fine.
[Quoted] Now this is funny. Are you sure you are running MySQL and not MariaDB? Because recent versions of MariaDB use the "unix_socket" authentication method to secure the root_at_localhost account. MySQL has a similar authentication plugin but AFAIK they don't enable it by default.
See: https://mariadb.com/kb/en/mariadb/unix_socket-authentication-plugin/
and
https://dev.mysql.com/doc/mysql-security-excerpt/5.7/en/socket-authentication-plugin.html
> In mysql log I have only access denied.
> Reinstalling mysql doesn't help. mysql_upgrade doesn't help, either.
[Quoted] Naturally. Account information is stored in the system database. And this is not touched by reinstallion.
> $ mysql --version
> mysql Ver 14.14 Distrib 5.7.17, for Linux (i686) using EditLine wrapper
Better use: SELECT version();
> Here you have my privileges:
> mysql> show grants for 'root'_at_'localhost';
[Quoted] Better use: SHOW CREATE USER 'root'_at_'localhost';
> Please help. I would like to avoid reinstalling Ubuntu.
[Quoted] Are you from the Windows world? Reinstalling never solves this kind of problem. Received on Fri Feb 10 2017 - 20:57:48 CET