0

I have been reading billions of answers/questions for that same error :

SQLSTATE[HY000] [1045] Access denied for user 'root'@'ALEXPC' (using password: YES)

I myself even handle this error like hundred of times during the past 10 years.

But this case is weird : both navicat and mysql workbench can connect to this mysql 8 ( and browse things ) just fine. Just my php code (which worked well on mysql 5.7) refuses to cooperate. Same user/password.

One more strange thing, my php machine name is capitalized in the error message after the first time:

  //    first  
     SQLSTATE[HY000] [1045] Access denied for user 'dev'@'alexpc' 
      // then  
 SQLSTATE[HY000] [1045] Access denied for user 'dev'@'ALEXPC'

And mysql "users and Previleges" tool says "Mysql only allows lowercase characters for hostnames, the account host will be updated accordingly".

P/s: I am using nginx-cgi on windows and php 7.3.4 php_pdo

I also set as recommended by Php website:

 default_authentication_plugin = mysql_native_password
  • 1
    One more strange thing, my php machine name is capitalized in the error message after the first time: It can be a result of NetBIOS direct-and-reverse lookup. What if authenticate using full name? full name with IP as a host part? – Akina Apr 16 at 11:16
  • @Akina I barely understand the NetBIOS things... in PHP code, the construct method only take url , username and pwd. The php machine name is taken by pdo lib behind the scene, nothing a developer like me can do – Phung D. An Apr 16 at 11:27
  • The php machine name is taken by pdo lib behind the scene Does when you specify username parameter as full one ('dev'@'alexpc' instead of 'dev') the construct method gives error? And what if to use DSN with uid=dev@alexpc;? – Akina Apr 16 at 11:39
  • @Akina : alexpc is my PC, it's the client, from which my php code looks like : $connection = new PDO('mysql:host=mysql8;port=3306', 'username', 'password',[others]) . Same for navicat and mysql workbench, I don't need to worry about my PC name. ( well, I did grant access for both alexpc and % so navicat/workbench have no problem connecting ) – Phung D. An Apr 16 at 13:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.