Sign Up

Have an account? Sign In Now

Sign In

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

Sorry, you do not have a permission to ask a question, You must login to ask question.

Forgot Password?

Need An Account, Sign Up Here
Sign InSign Up

ErrorCorner

ErrorCorner Logo ErrorCorner Logo

ErrorCorner Navigation

  • Home
  • Contact Us
  • About Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Contact Us
  • About Us
Home/ Questions/Q 790
Next
Answered
Kenil Vasani
Kenil Vasani

Kenil Vasani

  • 646 Questions
  • 567 Answers
  • 77 Best Answers
  • 26 Points
View Profile
  • 2
Kenil Vasani
Asked: December 18, 20202020-12-18T21:36:42+00:00 2020-12-18T21:36:42+00:00In: MySql, php

PHP with MySQL 8.0+ error: The server requested authentication method unknown to the client

  • 2
This question already has answers here:

php mysqli_connect: authentication method unknown to the client [caching_sha2_password]

(11 answers)

Closed last year.

I’m running MySQL version 8 on PHP 7.0.

I’m getting the following error when I try to connect to my database from PHP:

Connect Error: SQLSTATE[HY000] [2054] The server requested authentication method unknown to the client

PHP might show this error

Warning: mysqli_connect(): The server requested authentication method unknown to the client [caching_sha2_password] in D:\xampp\htdocs\reg\server.php on line 10

How can I fix this problem?

mysqlphp
  • 1 1 Answer
  • 10 Views
  • 0 Followers
  • 0
Answer
Share
  • Facebook

    1 Answer

    • Voted
    1. Kenil Vasani

      Kenil Vasani

      • 646 Questions
      • 567 Answers
      • 77 Best Answers
      • 26 Points
      View Profile
      Best Answer
      Kenil Vasani
      2020-12-18T21:36:30+00:00Added an answer on December 18, 2020 at 9:36 pm

      @mohammed, this is usually attributed to the authentication plugin that your mysql database is using.

      By default and for some reason, mysql 8 default plugin is auth_socket. Applications will most times expect to log in to your database using a password.

      If you have not yet already changed your mysql default authentication plugin, you can do so by:
      1. Log in as root to mysql
      2. Run this sql command:

      ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password
      BY 'password';  
      

      Replace ‘password’ with your root password. In case your application does not log in to your database with the root user, replace the ‘root’ user in the above command with the user that your application uses.

      Digital ocean expounds some more on this here Installing Mysql

      • 2
      • Share
        Share
        • Share on Facebook
        • Share on Twitter
        • Share on LinkedIn
        • Share on WhatsApp

    You must login to add an answer.

    Forgot Password?

    Sidebar

    Ask A Question
    • Popular
    • Kenil Vasani

      SyntaxError: invalid syntax to repo init in the AOSP code

      • 5 Answers
    • Kenil Vasani

      xlrd.biffh.XLRDError: Excel xlsx file; not supported

      • 3 Answers
    • Kenil Vasani

      Homebrew fails on MacOS Big Sur

      • 3 Answers
    • Kenil Vasani

      runtimeError: package fails to pass a sanity check for numpy ...

      • 3 Answers
    • Kenil Vasani

      Unable to resolve dependency tree error when installing npm packages

      • 2 Answers

    Explore

    • Most Answered
    • Most Visited
    • Most Voted
    • Random

    © 2020-2021 ErrorCorner. All Rights Reserved
    by ErrorCorner.com