15%

Save 15% on All Hosting Services

Test your skills and get Discount on any hosting plan

Use code:

Skills
Get Started
16.11.2023

Fixing the “SET PASSWORD Has No Significance for User root@localhost” Error in MySQL

The error "SET PASSWORD has no significance for user 'root'@'localhost'" occurs in MySQL when the server refuses to process a SET PASSWORD command for the root account — typically because the root user is authenticated via the auth_socket or unix_socket plugin rather than a traditional password-based method. In these configurations, MySQL delegates authentication to the operating system, making password-based credential changes meaningless at the SQL level.

This guide covers every root cause, the correct diagnostic sequence, and multiple resolution paths — including edge cases that surface on managed VPS environments, cPanel-based servers, and hardened production systems.

Why This Error Occurs: Root Cause Analysis

Understanding the exact trigger is essential before applying any fix. The error is not a permissions failure in the traditional sense — it is a signal that MySQL's authentication layer is bypassed entirely for the root account.

The auth_socket / unix_socket Plugin

On modern Debian, Ubuntu, and their derivatives, MySQL (and MariaDB) configure the root user to authenticate via the auth_socket plugin by default. When this plugin is active, MySQL verifies the connecting OS user's identity instead of checking a password. Consequently, any attempt to set a password using SET PASSWORD is rejected — the server considers the command irrelevant for that authentication model.

You can verify this immediately after logging in:

SELECT user, host, plugin, authentication_string
FROM mysql.user
WHERE user = 'root' AND host = 'localhost';

If the plugin column returns auth_socket (MySQL) or unix_socket (MariaDB), this is your root cause.

Other Contributing Factors

  • Insufficient privileges: The executing user lacks SUPER or SYSTEM_USER privileges required to modify root's credentials.
  • Restrictive my.cnf / my.ini directives: Options like skip-grant-tables or custom validate_password policies can interfere with password operations.
  • MySQL version mismatch: The SET PASSWORD syntax was deprecated in MySQL 8.0 and removed from certain contexts. The preferred method is ALTER USER.
  • Read-only system tables: On some cloud or containerized deployments, the mysql system schema may be partially locked.

Comparison: SET PASSWORD vs. ALTER USER vs. UPDATE

These three methods are not interchangeable. Choosing the wrong one for your MySQL version or authentication plugin will either produce the error in question or silently fail.

MethodMySQL Version SupportWorks with auth_socketRecommended
SET PASSWORD5.x, partially 8.0NoNo (deprecated)
ALTER USER5.7+, 8.0+Yes (switches plugin)Yes
UPDATE mysql.userAll versions (with flush)Yes (low-level)Emergency only
mysqladmin passwordAll versionsNoLimited use

Step-by-Step Resolution

Step 1: Log In to MySQL as Root

On systems using auth_socket, you must log in as the OS root user — no password prompt will appear:

sudo mysql -u root

If your system uses password authentication and you know the current password:

mysql -u root -p

Step 2: Confirm the Authentication Plugin

Run the diagnostic query:

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

Take note of the value in the plugin column before proceeding. This determines which fix applies to your situation.

Step 3: Verify Current Privileges

Before modifying authentication, confirm the root account's grant set:

SHOW GRANTS FOR 'root'@'localhost';

The output should include GRANT ALL PRIVILEGES ON *.* ... WITH GRANT OPTION. If it does not, you are likely connected as a user with insufficient rights — re-authenticate using sudo mysql to invoke OS-level trust.

Step 4: Switch to Password Authentication and Set a New Password

This is the primary fix when auth_socket or unix_socket is the active plugin. The ALTER USER statement simultaneously changes the authentication plugin and sets the password in a single atomic operation:

ALTER USER 'root'@'localhost'
  IDENTIFIED WITH mysql_native_password
  BY 'YourStrongPassword!9#';

FLUSH PRIVILEGES;

For MariaDB, the equivalent is:

ALTER USER 'root'@'localhost'
  IDENTIFIED VIA mysql_native_password
  USING PASSWORD('YourStrongPassword!9#');

FLUSH PRIVILEGES;

> Security note: On MySQL 8.0.34 and later, mysql_native_password is deprecated in favor of caching_sha2_password. For production systems, use:

>

> “`sql

> ALTER USER 'root'@'localhost'

> IDENTIFIED WITH caching_sha2_password

> BY 'YourStrongPassword!9#';

> “`

Step 5: Grant Full Privileges (If Required)

If the privilege check in Step 3 revealed incomplete grants, restore them explicitly:

GRANT ALL PRIVILEGES ON *.*
  TO 'root'@'localhost'
  WITH GRANT OPTION;

FLUSH PRIVILEGES;

Do not use the legacy GRANT ... IDENTIFIED BY syntax on MySQL 8.0+. That combined syntax was removed. Always separate the GRANT and ALTER USER statements.

Step 6: Verify the Fix

Confirm the plugin has been updated:

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

Exit MySQL and reconnect using the new password to validate end-to-end:

mysql -u root -p

Emergency Method: Resetting via skip-grant-tables

If you are locked out entirely and cannot authenticate, use the skip-grant-tables mode. This bypasses all privilege checks and should only be used in a controlled, offline maintenance window.

1. Stop the MySQL service:

sudo systemctl stop mysql
# or for MariaDB:
sudo systemctl stop mariadb

2. Start MySQL with grant tables disabled:

sudo mysqld_safe --skip-grant-tables --skip-networking &

The --skip-networking flag is critical — it prevents any remote connections during this insecure state.

3. Connect without credentials:

mysql -u root

4. Flush privileges, then update the password:

FLUSH PRIVILEGES;

ALTER USER 'root'@'localhost'
  IDENTIFIED WITH mysql_native_password
  BY 'YourStrongPassword!9#';

FLUSH PRIVILEGES;

5. Restart MySQL normally:

sudo systemctl restart mysql

Checking and Adjusting MySQL Configuration Files

The my.cnf (Linux) or my.ini (Windows) file can contain directives that interfere with password operations. Common locations:

  • /etc/mysql/my.cnf
  • /etc/my.cnf
  • /etc/mysql/mysql.conf.d/mysqld.cnf

Check for these problematic directives under the [mysqld] section:

skip-grant-tables       # Disables all privilege enforcement — remove after recovery
validate_password       # May reject passwords that don't meet complexity rules
bind-address            # Affects remote access, not password changes directly

If validate_password is enforcing a policy that rejects your chosen password, either meet the policy requirements or temporarily adjust the policy level:

SET GLOBAL validate_password.policy = LOW;
SET GLOBAL validate_password.length = 8;

Platform-Specific Considerations

cPanel and WHM Environments

On VPS with cPanel installations, MySQL root credentials are managed by cPanel itself. Manually altering the root password outside of WHM can break cPanel's internal database connections. Always use WHM > SQL Services > Change MySQL Root Password for these environments. If you must use the CLI, run /usr/local/cpanel/scripts/mysqlpasswd afterward to resync cPanel's stored credentials.

Managed VPS Environments

On a VPS Hosting environment where you have full root OS access, the sudo mysql approach (leveraging auth_socket) is the most reliable entry point. Avoid disabling auth_socket unless your application stack specifically requires password-based root authentication — OS-level authentication is architecturally more secure.

Dedicated Servers

On Dedicated Servers running hardened MySQL configurations, the validate_password plugin is frequently enabled with STRONG policy enforcement. Ensure your replacement password meets the minimum requirements: at least 8 characters, mixed case, digits, and special characters. You can check current policy settings with:

SHOW VARIABLES LIKE 'validate_password%';

Security Best Practices After Resolving the Error

Once the root password issue is resolved, apply these hardening steps immediately:

  • Run mysql_secure_installation to remove anonymous users, test databases, and remote root login.
  • Disable remote root login: Ensure no 'root'@'%' entry exists in mysql.user.
  • Create application-specific users with the minimum required privileges rather than using root for application connections.
  • Rotate credentials stored in application configuration files (.env, wp-config.php, database.yml) to match the new password.
  • Enable SSL/TLS for MySQL connections — particularly relevant if your application server and database server are on separate hosts. Pair this with a valid SSL Certificate on your web layer.
  • Audit the mysql.user table periodically to identify accounts with empty authentication_string values or overly broad host wildcards.

Technical Key-Takeaway Checklist

Use this as a rapid decision matrix when you encounter this error:

  • Check the plugin first — run SELECT plugin FROM mysql.user WHERE user='root' before attempting any fix.
  • Use ALTER USER, not SET PASSWORDSET PASSWORD is deprecated in MySQL 8.0+ and incompatible with socket-based authentication.
  • Always use sudo mysql on Ubuntu/Debian systems — OS-level trust bypasses the socket plugin without disabling it.
  • Never leave skip-grant-tables active in production — it removes all access control from your database server.
  • Separate GRANT from ALTER USER on MySQL 8.0+ — the combined GRANT ... IDENTIFIED BY syntax no longer exists.
  • On cPanel servers, use WHM or the cPanel resync script — direct CLI changes will break internal cPanel database sessions.
  • Validate the fix end-to-end — reconnect with mysql -u root -p after every change to confirm the new credentials work before closing your session.
  • Review my.cnf for validate_password directives if ALTER USER succeeds but the password is rejected.

Frequently Asked Questions

Why does SET PASSWORD work on some servers but not others?

The behavior depends on the authentication plugin assigned to the root account. On servers using mysql_native_password or caching_sha2_password, SET PASSWORD may still function in MySQL 5.7. On Ubuntu/Debian systems where auth_socket is the default, the command is rejected because no password is stored or checked. MySQL 8.0 further deprecated SET PASSWORD, making ALTER USER the only reliable cross-version method.

Can I re-enable auth_socket after switching to password authentication?

Yes. Run ALTER USER 'root'@'localhost' IDENTIFIED WITH auth_socket; and then FLUSH PRIVILEGES;. After this, sudo mysql will work again without a password, and mysql -u root -p will fail. This is the recommended configuration for systems where only local OS-authenticated access to root is required.

What is the difference between FLUSH PRIVILEGES and restarting MySQL?

FLUSH PRIVILEGES reloads the grant tables from disk into memory without restarting the service. It is sufficient after direct UPDATE mysql.user modifications. ALTER USER and GRANT statements write directly to the grant tables and take effect immediately — FLUSH PRIVILEGES is technically redundant after them but harmless and widely used as a safety measure.

Why does GRANT ALL PRIVILEGES ... IDENTIFIED BY fail on MySQL 8.0?

MySQL 8.0 removed the ability to create or modify users implicitly within a GRANT statement. The IDENTIFIED BY clause in GRANT was deprecated in MySQL 5.7 and removed in 8.0. You must use CREATE USER or ALTER USER separately, then issue the GRANT statement without the IDENTIFIED BY clause.

Is it safe to run a MySQL database on a shared hosting plan?

For low-traffic personal projects, Shared Web Hosting with managed MySQL is adequate. However, you will not have direct access to mysql.user, GRANT management, or configuration files. For any workload requiring direct administrative control over MySQL — including resolving errors like this one — a VPS Hosting environment with root OS access is the appropriate choice.

15%

Save 15% on All Hosting Services

Test your skills and get Discount on any hosting plan

Use code:

Skills
Get Started