0

I have MySql 8.0 freshly server installed. Initially, I was able to log in, but when I tried to connect to it through PHP PDO I got this error:

Fatal error: Uncaught PDOException: PDO::__construct(): The server requested "authentication method unknown to the client [caching_sha2_password]"

I read from StackOverflow a solution here

  • Open your my.cnf (in my case the my.ini file) and add the following entry (and restart MySQL)

  • [mysqld]

  • default_authentication_plugin=mysql_native_password

  • Create a user (your MYSQL_USER name) using the correct 8.0 syntax for generating the password (see below) <---- Altered my existing user
    "root"

  • IDENTIFIED WITH mysql_native_password

  • Flush the privileges and try again.

After I restarted the MySql service I'm now unable to log in to MySQL. with it saying this error now:

ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)

I want to be able to log in through PHP PDO, but I can't even log back in through regular command prompt or MySQL Workbench. Any help on this would be great.

Yodavish
  • 119
  • 12
  • Have a look at [this post](https://stackoverflow.com/questions/10299148/mysql-error-1045-28000-access-denied-for-user-billlocalhost-using-passw), not a duplicate, but you'll probably find you have the same issue as the person who asked the question. – D_Breedt Feb 06 '19 at 18:51
  • it says to create a new user with "@localhost" I can't even log in to create a new user? – Yodavish Feb 06 '19 at 19:03
  • try maybe resetting the mysql root password? Here's an [article](https://www.a2hosting.co.za/kb/developer-corner/mysql/reset-mysql-root-password) on how to do it via SSH. Is this a linux server? – D_Breedt Feb 06 '19 at 19:12
  • Windows Server 2012 R2, I'll give a try to reset the password. – Yodavish Feb 06 '19 at 19:17
  • Sorry, I'm no good at Windows, wish I could be of more help :) – D_Breedt Feb 06 '19 at 19:18
  • @D_Breedt didn't work :( when I stopped the services, and put in the below the [mysqld] "skip-grant-tables", restarted the services and try run it through command line by just going to the bin>mysql I get this error: ERROR 2003 (HY000): Can't connect to MySQL server on 'localhost' (10061) Then afterwards the MySql server stops. – Yodavish Feb 06 '19 at 19:27
  • What version of PHP? Do you have `mysqlnd` running with PHP? – Rick James Aug 21 '19 at 21:32
  • Is your PHP _inside_ the container with MySQL? Or _outside_? – Rick James Aug 21 '19 at 21:32

0 Answers0