Hardware FixRecommendedDevice not working? Your driver may be the problemCheck updates for common hardware issues.Fix DriversHalloween DealsAmazon USHalloween week deals: useful picks before month-endAmazon US: current deals, useful picks and tech finds.Check DealsClean PCRecommendedOne scan can reveal what keeps slowing WindowsLook for cleanup and repair opportunities.Run Scan×
Skip to content
World desk9 min

How to Fix the MySQL Root Password Not Working

Resolve MySQL ERROR 1045 by checking the exact root host account, bypassing stale option files, and following the safe Unix or Windows password-reset procedure.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Most MySQL ERROR 1045 (28000): Access denied for user 'root'@'localhost' failures come from one of four causes: the password is wrong, a client option file is supplying a different password, MySQL is matching a different host-specific root account, or the server is using an authentication setup you did not expect. Start with mysql --no-defaults -u root -p to remove option-file interference. If the password is genuinely lost, reset it with MySQL’s temporary recovery mode, then stop that insecure server and restart normally.

The exact account is important: 'root'@'localhost', 'root'@'127.0.0.1', and 'root'@'hostname' are separate account identities. Follow the diagnostic steps below before changing credentials, because a reset applied to the wrong host row will not fix the connection you are actually making.

As an Amazon Associate I earn from qualifying purchases.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

What MySQL error 1045 is telling you

The usual message is ERROR 1045 (28000): Access denied for user 'root'@'localhost'. MySQL may append using password: YES or using password: NO.

  • Using password: YES means the client sent a password and MySQL rejected it. The password may be incorrect, or it may belong to a different host-specific account.
  • Using password: NO means no password was sent. This is expected only when the account is configured for passwordless access, such as a server first initialized with mysqld --initialize-insecure, or when the client command omitted -p.

Do not assume that the word root identifies one universal account. MySQL account names contain both a user and a host. The server chooses the best matching row for the connection source, so a socket connection to localhost can authenticate against a different row than a TCP connection to 127.0.0.1 or a server hostname.

#1 Best Overall
Sale
TOZO A1 Wireless Earbuds Bluetooth 5.3 Light Weight in Ear Headphones | IPX5 Waterproof,2 Mics for AI Calls,Immersive Premium Sound Bass Headset with Charging Case,32 EQ via App Black
  • [Ultra-Lightweight Ear Buds Designed for Small Ears] Each earbud weighs only 3.7g and features a compact, ergonomic in-ear design made especially for small ears. Secure, low-profile, and comfortable for workouts, all-day wear or overnight sleeping.The ultra-slim profile sits flush in your ear with no hard edges poking or rubbing, so you can even sleep on your side without discomfort.
  • [Immersive Stereo Sound with TOZO OrigX Technology] TOZO OrigX tuning delivers clear vocals, balanced mids, and natural stereo sound for music, podcasts, and videos.
  • [Long Battery Life for Daily Use] Get up to 7 hours of playtime on a single charge, with up to 32 hours total using the charging case—ideal for workdays, commuting, and extended listening sessions.
  • [Bluetooth 5.3 & Stable Connection] Bluetooth 5.3 provides fast pairing, stable wireless performance, and reduced dropouts as you move around home or office.
  • [Deep Bass with Clear Vocals] High-performance drivers produce punchy bass while keeping vocals clean and detailed for everyday listening.

Why the host part changes the result

These are distinct accounts:

'root'@'localhost'
'root'@'127.0.0.1'
'root'@'db.example.internal'

A password that works for one row says nothing about the others. The same applies to applications: changing an application from a local socket to TCP can change the account row MySQL evaluates.

Why an option file can make a correct password fail

The MySQL client reads option files that can contain a user name, host, port, socket, or password. A stale [client] or [mysql] entry can silently override what you think you are testing. Bypass those files for diagnosis:

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
mysql --no-defaults -u root -p

The client will prompt for the password instead of taking one from an option file. Never put a password directly on the command line, because it can be exposed in shell history or process listings.

Run this diagnostic sequence before resetting anything

  1. Save the complete error. Record whether it says using password: YES or using password: NO, and note the displayed user and host.
  2. Make a clean local test. Run mysql --no-defaults -u root -p from the database server. Enter the password interactively.
  3. Test the actual network endpoint. If the intended connection is remote or uses TCP, specify both endpoint values: mysql --no-defaults -h hostname -P 3306 -u root -p. Replace hostname and 3306 with the endpoint you really use. A different host value can select a different root row.
  4. Use another administrator if one exists. A working administrative account lets you inspect the root rows before making changes.
  5. Check service state and the server error log. A stopped server, failed startup, permission problem, or wrong data directory can look like an authentication problem when the client is connecting to a different instance than expected.

Inspect the account rows with a working administrator

After connecting with an account that has permission to read the grant tables, inspect the user, host, and authentication plugin:

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

Compare the returned host values with the command you are using. Also verify that the service you restarted is the same MySQL instance reached by your client’s socket, hostname, and port.

Fixes when you still know the password

Remove stale client settings

First retry with --no-defaults. If that works, locate the option file that supplied the wrong value and remove or correct the obsolete host, port, user, or password entry. Keep credentials out of shared option files unless their permissions are restricted and you understand exactly which client programs read them.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #2
Sale
Smart Watch for Men Women Compatible with iPhone Samsung Android Phone 1.69 inch Full Touch Screen IP68 Waterproof Bluetooh Fitness Tracker Heart Rate/Sleep Monitor (Black)
  • 【IP68 Waterproof Multifunctinal Smart Watch】Torjalph fitness activity tracker smart watch is IP68 waterproof technology ,you can wear it when swimming,handwashing,it's rain-proof which means that you perform multiple exercise modes outside without worrying about sweat or rain corroding your fitness smart watch,and this watch equipped with a 230 mAh large capacity battery magnetic charging ,and this sports activity tracker watch can be used 5-7 days If fully charged.
  • 【Larger 1.83'' Full Screen Watch & Multi-dial Selection】1.83 inch full HD color touch screen smart watch for men / women provides excellent 240*284 resolution image quality ,This Bluetooth smart watch offers a better touch experience and remarkable immersion and ,more than 200 watch faces for you to choose from App"Da Fit ", you can change the dial style according to your mood to wear keeping the world on your wrist
  • 【Accurate Activity Tracker Smart Watch 】sports watch activity tracker uses sweat and dust resistant breathable silicone strap, our Fitness Tracker Smart Watch for Android iOS Phones supports 12 sports modes,walking,running,bicycle,swimming,badminton,basketball,football,rope skipping. This bluetooth calls smart watch for men women is lightweight and stylish, bringing more convenient and relaxing sports experience while also providing more protection.
  • 【Your 24 Hour Personal Daily Health Monitor】Fitness watch for women men full touch screen IP67 waterproof bluetooth smartwatch for Android iOS Phones with heart rate blood pressure monitor multifunction Andriod smart watch with steps counter sleep monitor sports fitness watch, monitoring blood oxygen saturation allows you to understand your physical condition in real time to track fitness progress ,to know your health status in time.
  • 【More Functions Bluetooth Call Smart Watch】This fitness activity smart watch full screen for iPhone and Android phones includes a bunch of new features including:The bluetooth smart watch can hang up the phone, receive and display WhatsAPP /Text /Facebook /Twitter /Messenger reminder.Support sedentary reminder, alarm clock, stopwatch, timer,weather information,music control, remote camera control compatible with Android 5.0 and above or iOS 9.0 and above smartphones.

Check shell and application handling

Passwords containing spaces, shell metacharacters, or non-ASCII characters can be altered by a shell script or deployment variable before MySQL receives them. Interactive -p entry separates the database test from that quoting problem. If the interactive login succeeds but an application fails, compare the application’s host, port, socket, user, and password character-for-character with the successful command.

Use the same host form as the account

If localhost works but 127.0.0.1 fails, or the reverse, you are probably reaching different account rows or different connection methods. Test each explicitly rather than changing passwords repeatedly:

mysql --no-defaults -h localhost -u root -p
mysql --no-defaults -h 127.0.0.1 -P 3306 -u root -p

For a Unix socket, use the socket configured for the running instance. For TCP, specify the hostname and port. The successful form identifies which account row and server endpoint your credentials actually match.

Account created without a password

A server initialized with mysqld --initialize-insecure can start with root having no password. In that specific case, a command without a password prompt may work, but leaving the account passwordless is unsafe. Set a password immediately after the first successful administrative login with ALTER USER.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Choose the appropriate recovery method

Situation Recommended path Downtime and exposure
Password is known; another login fails Use --no-defaults, then test the exact host and port. Inspect root rows with another administrator if available. No server downtime; no special exposure.
Password forgotten on Unix-like system Temporarily start mysqld with --skip-grant-tables (normally also --skip-networking), run FLUSH PRIVILEGES, then ALTER USER. Requires a restart. While enabled, anyone who can reach the temporary server can connect without a password and has all privileges.
Password forgotten on Windows Use a one-line --init-file containing ALTER USER, then remove the file and restart the service normally. Requires stopping the service. The init file contains the new password and must be deleted immediately.
Another administrative account exists Use that account to inspect mysql.user and run ALTER USER 'root'@'host' IDENTIFIED BY ... for the correct host row. Usually no special recovery mode; normal privilege checks apply.

Reset a forgotten root password on Unix-like systems

The following is the generic MySQL recovery sequence. Service names and configuration paths differ by distribution, so use the service manager and data directory belonging to your installation.

1. Stop the normal MySQL service

Stop MySQL cleanly with the operating system’s service manager before starting a temporary server. Confirm that no normal mysqld process is still listening on the production socket or port.

Rank #3
New Bee Guitar Cable 10ft Electric Instrument Bass AMP Cord
  • [Low Noise High Fidelity] New bee guitar cord with 22AWG oxygen-free-copper center conductors provides enhanced signal transfer, the PVC insulation material and the high-density stranded copper double shield provide noise rejection for quiet operation
  • [Ideal for Choice] New bee 1/4 straight and right angle metal connectors, ensures a secure connection in any instrument, pedal, or amp jack. L shape great fro on stage guitar stands
  • [Wide Compatible] Suitable for mixer, power amplifier, microphone, effector, decoder, equalizer, electoronic organ, electric guitar, electric bass and other electronic equipments. Widely used in the installation of smart home, karaoke speaker, professional stage audio, etc
  • [Easy Disassemble] Making incidental repairs quick and easy! Very nice, flexible cable
  • [Dont Hesite to Order] 24 hours customer services and professional technology team are standing by

2. Start a local recovery server

Start mysqld with grant-table checks disabled. Add --skip-networking so the temporary instance accepts local connections only:

mysqld --skip-grant-tables --skip-networking

Run the daemon as its normal service account, commonly mysql. If you launch it from a root shell, include --user=mysql or use the service account explicitly. Starting the server as Unix root without changing its effective user can create root-owned data or log files that prevent the normal service from starting later.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

--skip-grant-tables is an emergency measure, not a permanent configuration. MySQL warns that it permits passwordless, all-privilege connections and disables normal account-management statements until the grant tables are reloaded. Keep the server local and make the recovery interval as short as possible.

3. Connect locally without credentials

In a second terminal on the same machine, connect without -u or -p:

mysql

If the client reaches a different socket or port, specify the temporary server’s local socket or endpoint. Do not expose this instance to a network.

4. Reload the grant tables

At the MySQL prompt, run:

FLUSH PRIVILEGES;

This reloads the account data and re-enables account-management statements for the recovery session.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #4
BSIMB 15.6" Digital Family Calendar & Chore Chart, No Subscription Fees
  • Digital Family Calendar: BSIMB digital calendar wall touch screen puts an end to your chaotic life. Designed for busy families, the digital calendar keeps you organised and in step with your family. Assign different colours and tasks to each family member to make family scheduling easier and more intuitive.
  • Easy Setup and Auto-Sync: Plug in, connect to WLAN and auto-syn your electric calendar in minutes. Digital wall calendar compatible with Google calendar, iCloud calendar, Outlook calendar, Cozi calendar and Yahoo calendar. Add events directly on the device or through the ecalendar app. Electronic calendar stays current whether you're at work or traveling—no manual updates needed.
  • All-In-One Home Assistant: Smart calendar builds habits and encourage independence with personalised chores. Display daily meal plan to reduce the daily ‘What's for dinner?’ stress. To-do lists keep track of everything you want. Turning chores into valuable achievements with stars and rewards, making life easier and more enjoyable.
  • Manage Anytime Anywhere: BSIMB electronic calendar for family stay connected with the powerful ecalendar app. Access and manage your digital wall calendar anytime, anywhere with free features like stars & rewards, photo screensaver, chore charts, meals plans, to-do lists etc. Electronic planner paid features like Magic Import tailor advanced tools for users with special needs.
  • Stay in Touch with Loved Ones: Share photos or videos from your phone to electronic wall calendar with app, instantly update your life moment, and keep in touch with your family, especially those who are far away; you can also surprise your smart calendar digital wall by sending him a wish card; it's also great for keeping tech-illiterate elders in touch with the youngsters.

5. Assign a new password with ALTER USER

Change the password on the exact host row used by the intended connection. For the common local account:

ALTER USER 'root'@'localhost' IDENTIFIED BY 'MyNewPass';

If your diagnostic work showed that the application uses another host row, alter that row instead. Choose a long, unique password and store it in a protected password manager. Do not paste it into shell history or commit it to configuration files.

6. Exit and stop the temporary server

Exit the MySQL client, stop the recovery mysqld process, and remove any temporary --skip-networking or --skip-grant-tables settings. Do not simply leave the process running in the background.

7. Restart MySQL normally

Start the service through its normal service manager and original configuration. If startup fails, inspect the server error log for files created with the wrong owner, an occupied port, an incorrect data directory, or an invalid option left from recovery.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

8. Verify with a clean login

Test a fresh normal connection:

mysql --no-defaults -u root -p

Then test the same hostname, port, and socket used by the application. A successful local login does not prove that a remote host-specific account or TCP endpoint is configured correctly.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Reset the password on Windows with an init file

MySQL documents an alternative for Windows that avoids leaving grant tables disabled. It still requires downtime and careful handling of a file containing the new password.

  1. Stop the MySQL Windows service from Services or an elevated command prompt.
  2. Create a one-line text file, such as C:mysql-init.txt, containing exactly:
ALTER USER 'root'@'localhost' IDENTIFIED BY 'MyNewPass';
  1. Find the service’s Path to executable in the Windows service manager. This reveals the installation’s required --defaults-file path when one is used.
  2. Start mysqld manually with the installation’s normal options, adding --init-file=C:mysql-init.txt. Include the correct --defaults-file shown by the service definition.
  3. Wait for the server to execute the statement, then stop that manually started process.
  4. Delete C:mysql-init.txt. The file is a plaintext credential and must not remain on disk.
  5. Start the Windows service normally and test with mysql --no-defaults -u root -p, specifying the intended host and port if they are not the defaults.

If the service does not start with the manual command, do not guess at data-directory or defaults-file values. Compare the command with the service’s original executable path and consult the server error log.

Authentication-plugin and version cautions

Use ALTER USER for current MySQL releases. Older tutorials that directly update password columns in grant tables may be unsupported or may write the wrong format for your server version.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

The mysql_native_password plugin is deprecated as of MySQL 8.0.34. Do not force it merely because an old guide uses IDENTIFIED WITH mysql_native_password. Plugin-specific IDENTIFIED WITH operations also require suitable account-management privileges. If an existing account uses a particular plugin, inspect it first and choose syntax supported by the exact MySQL version running your server.

When another administrator is available, the earlier SELECT User, Host, plugin FROM mysql.user query shows which plugin is currently assigned. Preserve a working, supported plugin unless a documented compatibility requirement calls for a change.

When the reset appears not to work

The error still says using password: YES

Repeat the clean command with --no-defaults, then verify the host and port. If the account was changed on localhost but the client connects to a hostname or TCP address, alter or test the matching host row instead.

The error says using password: NO

The client did not send a password. Add -p for an interactive prompt, or investigate whether an option file or application configuration intentionally omitted it. If the server was initialized insecurely, set a password rather than relying on passwordless access.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

FLUSH PRIVILEGES works but ALTER USER is rejected

Confirm that you actually ran FLUSH PRIVILEGES; in the recovery session and that the statement names an existing user-and-host row. In normal mode, use an account with the required account-management privileges. Do not replace ALTER USER with an undocumented direct update to password columns.

The server will not start after recovery

Check ownership of the data and log files, especially if the temporary daemon was launched as Unix root. Restore ownership to the normal MySQL service account, remove recovery-only options, and read the error log for the first startup failure rather than repeatedly restarting.

The command works but the application still fails

Compare the application’s connection host, port, socket, user, and password with the exact command that succeeded. Applications may use a different endpoint, a connection pool with an old password, or a separate secret store. Restart or reload the application only after its stored credentials have been corrected.

Final security and verification checklist

  • The temporary server has been stopped.
  • MySQL is running normally without --skip-grant-tables.
  • Any temporary --skip-networking setting has been removed.
  • A Windows init file, if used, has been deleted.
  • The new password was tested with mysql --no-defaults -u root -p against the intended host and port.
  • The application uses the same endpoint, account, and password that were tested manually.
  • No plaintext password remains in shell history, process arguments, temporary files, or world-readable configuration.
  • The root password is unique, long, and stored securely; applications use separate least-privilege accounts where possible.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Leave a Reply

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

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
Windows Errors? Fix Them Before They SpreadFree repair scan
Outdated Drivers Are Slowing You DownFree scan - exact matches

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.