Era Host hosting
EraHost – Free Domain, Cheap Hosting!
Client Area
Support 24/7
Menu

Using method 'mysql_native_password' failed with message: access denied for user

3 min read
29.05.2026

Verify Username and Password

  • Check if the username and password used in the connection string are correct.
  • Test the credentials manually:
    mysql -u your_user -p
    • If login fails, reset the password:
      ALTER USER 'your_user'@'localhost' IDENTIFIED BY 'your_new_password';
      FLUSH PRIVILEGES;
Linux VDS
High performance for your projects
  • Root access and flexible setup
  • Control panel
  • NVMe disks
  • DDR5
Linux VDS

Check Authentication Plugin

  • Ensure that the user is configured to use mysql_native_password.
  • Run the following SQL query:
    SELECT user, host, plugin FROM mysql.user WHERE user = 'your_user';
  • If the plugin column shows caching_sha2_password, change it to mysql_native_password:
    ALTER USER 'your_user'@'localhost' IDENTIFIED WITH mysql_native_password BY 'your_new_password';
    FLUSH PRIVILEGES;

Check Host Restrictions

  • MySQL may restrict the user to connections from certain hosts. Check:
    SELECT user, host FROM mysql.user WHERE user = 'your_user';
  • If the user is restricted to localhost, but the connection is coming from another server, allow access from all hosts:
    GRANT ALL PRIVILEGES ON *.* TO 'your_user'@'%' IDENTIFIED BY 'your_new_password';
    FLUSH PRIVILEGES;

Verify the Connection String

Ensure the connection string in your application matches the MySQL credentials.

mysql_native_password Access Denied
Force native_password — client requests, server must allow.

For closely related MySQL 0x80004005 troubleshooting topics, see MySqlConnector Access Denied (admin guide), MySql.Data 0x80004005 — Causes and Fixes, and MySQL Error #1227 — SUPER Privilege.

Example for C#:

string connectionString = "Server=localhost;Database=mydb;User ID=your_user;Password=your_new_password;";

If connecting remotely, replace localhost with the server's IP address or hostname.

Ensure MySQL is Listening for Remote Connections

  • Open the MySQL configuration file (my.cnf or my.ini) and check the bind-address:
    bind-address = 0.0.0.0
  • Restart MySQL after making changes:
    sudo systemctl restart mysql

Check Firewall and Port 3306

  • Ensure the firewall allows traffic on port 3306:
    sudo ufw allow 3306/tcp
  • Verify MySQL is listening on port 3306:
    netstat -tulnp | grep mysql

Update MySQL Connector

Ensure that the MySQL client or connector used by the application supports mysql_native_password:

  • C#:
    Install-Package MySql.Data -Version 8.0.33
  • Python:
    pip install --upgrade mysql-connector-python
  • Node.js:
    npm install mysql2@latest

Final Test

  1. Restart the application.
  2. Check the database logs for any further errors:
    tail -n 50 /var/log/mysql/error.log
  3. Verify that the user can connect and authenticate successfully.

By following these steps, the "Access Denied for User using 'mysql_native_password'" error should be resolved.

Frequently asked questions
`SELECT user, host, plugin FROM mysql.user WHERE user = 'app';` shows per-user plugin. If MySQL 8 default, you'll see `caching_sha2_password`. Client requesting `mysql_native_password` against this user fails because plugins don't match. Fix at one end or the other.
`ALTER USER 'app'@'%' IDENTIFIED WITH mysql_native_password BY '';` — requires the password again (mysql_native_password stores a different hash). After running, the user is now negotiable with old-style auth. Old clients work; modern clients still work (both support native_password).
If `app@'localhost'` exists but not `app@'%'`, connecting from any other host fails — even with correct password and matching auth plugin. Verify with: `SELECT user, host FROM mysql.user WHERE user = 'app';`. Add the missing host: `CREATE USER 'app'@'192.0.2.5' IDENTIFIED BY ''; GRANT ALL ON db.* TO 'app'@'192.0.2.5';`.
Correct — `REQUIRE SSL` enforces TLS. Connection-string-side: pass `SslMode=Required` (.NET), `sslmode='required'` (Python), `ssl: {}` (Node mysql2). Server's CA cert may need to be trusted client-side too. Verify with `SHOW VARIABLES LIKE '%ssl%';` on server, confirm have_ssl is YES and ssl_ca/cert/key are set.
Related articles
Fixing MySqlConnector.MySqlException (0x80004005): Access Denied for User
Fixing "550 5.7.1 Service Unavailable — Client Host Blocked Using Spamhaus"
421 Too Many Connections (10) From This IP — Shared IP Usage