You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

WordPress与MySQL报错:服务器请求客户端未知的认证方式

Fix for "The server requested authentication method unknown to the client" with MySQL 8.0 + PHP 7.x + WordPress

Hey, I’ve dealt with this exact headache before—let me break down what’s going on and how to fix it quickly:

Why this error happens

MySQL 8.0 switched its default authentication plugin to caching_sha2_password, which is more secure but isn’t supported by older PHP 7.x MySQLi extensions. That’s why your WordPress can’t connect, even when you use a "safe" password or enter the wrong one (the error is about the authentication method, not the password itself).

Your earlier attempt with old_passwords=1 failed because that setting was removed in MySQL 8.0—it’s only for super old MySQL versions (pre-5.6), so adding it breaks the service entirely.

Step-by-step fix

Here’s what you need to do to get WordPress connecting properly:

  1. Log into MySQL as root
    Open your terminal/command prompt and run:

    mysql -u root -p
    

    Enter your root password when prompted.

  2. Check your WordPress database user’s authentication plugin
    Replace wp_user with the actual username you created for WordPress, then run:

    SELECT user, host, plugin FROM mysql.user WHERE user = 'wp_user';
    

    You’ll see plugin set to caching_sha2_password—that’s the culprit.

  3. Update the user to use the compatible authentication plugin
    Replace wp_user, localhost (use % if your WordPress is on a different server), and your_secure_password with your details:

    ALTER USER 'wp_user'@'localhost' IDENTIFIED WITH mysql_native_password BY 'your_secure_password';
    
  4. Flush MySQL privileges
    Run this to make sure the changes take effect immediately:

    FLUSH PRIVILEGES;
    
  5. Restart your MySQL service

    • On Windows: Open Services, find MySQL, right-click and select "Restart"
    • On Linux: Run sudo systemctl restart mysql
  6. Test the WordPress connection
    Go back to your WordPress setup page, enter the updated credentials (username, new password, database name), and it should connect without the authentication error.

Quick note for future reference

If you ever upgrade PHP to 7.4 or later, those versions do support caching_sha2_password—so you can switch the user back to that plugin for better security once you’re on a newer PHP version.

内容的提问来源于stack exchange,提问作者tinashe.chipomho

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.29 07:12:43