Bobcares Logo
Search Call 1-800-383-5193 Emergency Contact
Bobcares Logo
Search Call 1-800-383-5193 Emergency Contact
Emergency Contact

Unlock MySQL Root Account When Access Denied for User Root Localhost Account is Locked

by Rinoy | Sep 25, 2025 | Latest, MySQL | 0 comments

Learn how to unlock MySQL root account when access denied for user root localhost account is locked error appears. Simple commands and solutions inside. Our MySQL Support Team is always here to help you.

Unlock MySQL Root Account When Access Denied for User Root Localhost Account is Locked

Seeing access denied for user root localhost account is locked can throw anyone off guard, especially when applications suddenly stop connecting to the database. This error usually means that the root account in MySQL has been marked as locked. Fortunately, you can bring it back without losing your data. Let’s go through the direct commands and methods that will help you unlock the account and get things working again.

access denied for user root localhost account is locked

An Overview

  • Why This Error Appears
  • Confirming Account Status
  • Unlocking the Account
  • Password Reset Considerations
  • For MacBook Pro and MAMP Users

Why This Error Appears

This error occurs when the root account is locked due to strict security policies, repeated failed login attempts, or even after upgrades. When the account is locked, applications fail to connect and throw the following error:

[3118] Access denied for user 'username'@'localhost'. Account is locked.

Confirming Account Status

To be certain that the account is locked, log in with an alternative admin user and run:

mysql> SELECT user, host, account_locked FROM mysql.user where user = 'username';
+------------------+--------------------------+----------------+
| user | host | account_locked |
+------------------+--------------------------+----------------+
| username | localhost | Y |
+------------------+--------------------------+----------------+
4 rows in set (0.00 sec)

If the account_locked column shows Y, the account is indeed locked.

Subscribe to our newsletter for the latest updates, news, and features.

Unlocking the Account

Once confirmed, you can unlock the account with:

ALTER USER 'username'@'hostname' ACCOUNT UNLOCK;
  • ‘username’: MySQL user’s name.
  • ‘hostname’: Host or IP.
  • ACCOUNT UNLOCK: Removes the lock.

For example, if the lock is only for localhost:

ALTER USER username@localhost ACCOUNT UNLOCK;

Now, since accounts can be locked on multiple hosts, it’s better to recheck with:

mysql> SELECT user, host, account_locked FROM mysql.user WHERE user = 'username';
+-------+---------------------------+----------------+
| user | host | account_locked |
+-------+---------------------------+----------------+
| username | 10.0.0.2 | Y |
| username | localhost | N |
| username | cloudlinux7.11-90-0-6.tld | Y |
+-------+---------------------------+----------------+
4 rows in set (0.00 sec)

Run the ALTER USER … ACCOUNT UNLOCK; command again for each locked host.

Password Reset Considerations

Sometimes unlocking is not enough, especially when the default authentication plugin causes trouble. MySQL 8+ uses caching_sha2_password by default, but many prefer mysql_native_password for local setups. You may need to reset the root password after changing the plugin.

Also, pay attention to password policy variables. You can check them with:

mysql> SHOW VARIABLES LIKE 'validate_password%';
+--------------------------------------+--------+
| Variable_name | Value |
+--------------------------------------+--------+
| validate_password_dictionary_file | |
| validate_password_length | 8 |
| validate_password_mixed_case_count | 1 |
| validate_password_number_count | 1 |
| validate_password_policy | MEDIUM |
| validate_password_special_char_count | 1 |
+--------------------------------------+--------+
6 rows in set (0.01 sec)

By lowering the policy, for instance:

SET GLOBAL validate_password.policy=LOW;

you can reset passwords with fewer restrictions. Restart MySQL after making changes, then use mysqladmin to reset the root password.

For MacBook Pro and MAMP Users

If you are on a MacBook Pro using MAMP, take a backup of your htdocs folder, uninstall MAMP, and reinstall it. This often resolves cases where the root account remains locked even after attempting changes.

[If needed, Our team is available 24/7 for additional assistance.]

Conclusion

The error access denied for user root localhost account is locked is not the end of the road. By checking the account status, unlocking it for all hosts, adjusting password policies if needed, and resetting the password, you can restore access quickly. For Mac users, a clean reinstall of MAMP may be the final step. With these methods, your database access will be back without unnecessary downtime.

Related posts:

    1. Incompatible with sql_modeonly_full_group_by
    2. MySQL flush privileges Ansible | All About
    3. MySQL Auto increment GUID | Which one is better?
    4. MySQL Aggregate Function To Concatenate Strings: A Note on

Submit a Comment Cancel reply

Your email address will not be published. Required fields are marked *

Recent Posts

  • A 15-Minute Self-Hosted RAG Stack Tutorial: From Zero to Production
  • Designing Data Pipelines That Prevent Outages Across Global Systems
  • Deployment Automation: Deploy With Efficiency and Consistency
  • What Is Proactive Monitoring? A Complete Guide
  • AI Use Cases: How Artificial Intelligence Is Used Across Industries

Categories

  • Advanced Vulnerability
  • AI Services
  • AI Support
  • AIOps
  • Amazon Web Services (AWS)
  • Apache
  • API Integration
  • Application Development
  • Azure
  • Cloud Cost Optimization
  • Cloud Management
  • Cloud-Native Application
  • Cloudflare
  • cPanel
  • cPanel migration
  • Cyberpanel
  • DDoS
  • Development Service
  • DevOps
  • DevOps Consulting
  • DevSecOps
  • Digital Transformation
  • DigitalOcean
  • DirectAdmin
  • Docker
  • Drupal
  • Ecommerce
  • Filezilla
  • FTP
  • Google cloud platform
  • HAProxy
  • Headless CMS Integration
  • Hosting Support
  • IIS
  • Infrastructure Management & Optimization
  • Kubernetes
  • KVM
  • Laravel
  • Latest
  • Linode
  • Litespeed
  • LXC/LXD
  • Magento
  • Mobile App Development
  • MongoDB
  • Moodle
  • MySQL
  • NFS
  • Nginx
  • OnApp
  • Outsourced Support
  • OVH
  • ovirt
  • pfsense
  • Plesk
  • PostgreSQL
  • PowerDNS
  • Product Engineering
  • Proxmox
  • RedHat
  • Redis
  • Sendmail
  • Server Administration
  • Server Management
  • Software Development
  • SQLServer
  • Technical Support
  • UI/UX
  • Virtualizor
  • VMware
  • VPN
  • Vulnerability Scanning
  • Vultr
  • Web Development
  • Windows
  • WordPress
  • WordPress Hosting
  • WordPressHA

Subscribe to our newsletter

Footer newsletter

Email sales@bobcares.com | Phone 1-800-383-5193

Product Engineering

  • MVP Build
  • MVP to Scale
  • Product Maintenance

Digital Transformation

  • Process Digitization & Automation
  • Systems Integration & Workflow Orchestration
  • Data Enablement & Decision Support
  • Application & Platform Modernization
  • Transformation Execution & Delivery Enablement

AI Services

  • AI Readiness & Use-Case Discovery
  • AI Integration & Application Enablement
  • Intelligent Automation & AI Workflows

Infrastructure Management

  • Always-On Infrastructure Management
  • Proactive Monitoring & Incident Prevention
  • Cloud Cost Control & Optimization (FinOps)
  • Outsourced IT & End-User Support
  • Managed Infrastructure Execution Support

DevOps & Automation Services

  • CI/CD & Release Automation
  • Infrastructure as Code & Platform Standardization
  • Reliability Engineering & Observability
  • DevSecOps Enablement
Product Engineering +
Web Development MVP to Scale Builds Microservices Architecture Agile & Dev Team Augmentation Mobile Apps Ecommerce UI/UX Design QA & Test Automation
Digital Transformation +
Legacy Modernization Workflow Automation Data-Driven Dashboards CRM / ERP Integration Business Process Re-engineering
AI Services +
AI & Machine Learning AIOps Intelligent Automation Business Intelligence & Analytics AI Installation & Compute
Infrastructure Management +
Cloud Setup Cloud Migration Managed Cloud Services Server & Hosting Cost Optimization Performance Optimization Outsourced Support
DevOps & Automation Services +
CI/CD Setup Kubernetes & Docker Infrastructure as Code Cloud-Native Migration DevSecOps
Cybersecurity & Compliance Services +
Security Hardening VAPT Incident Response Backup & DR

© 2026 Bobcares. All Rights Reserved.

  • Careers
  • |
  • Cookie Policy
  • |
  • GDPR
  • |
  • Privacy Policy
  • |
  • Terms and Service
  • LinkedIn
  • YouTube
  • Instagram
  • Facebook

Preview of the new Bobcares experience
NEW UPDATE
See What’s New
at Bobcares

Discover a faster, clearer view of our services and expertise.


Explore the New Experience
Arrow Right