October DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsPC HealthRecommendedCrashes, freezes, slowdowns? Check your PC nowSpot repairable issues before they interrupt work.Check PCOctober DealsAmazon USDeal season is back - check today's better picksAmazon US: current deals, useful picks and tech finds.See Picks×
Skip to content
VGSources
Blog

What Is the Default MySQL Password? How Initial Credentials Work and How to Reset Root

MySQL does not use one universal default password. This guide explains temporary and passwordless initialization, exact ALTER USER commands, host-specific accounts, and the secure recovery procedure for a forgotten root password.
Length9 min Posted Quest giverVGSources Team
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

MySQL has no universal default password. The initial credential depends on how the server’s data directory was initialized and on the installer used. A normal mysqld --initialize run creates root@localhost with a randomly generated, expired temporary password recorded in the server error log. mysqld --initialize-insecure creates the initial root account without a password. In both cases, set a strong permanent password immediately with ALTER USER.

What the “default MySQL password” actually means

People often try root, mysql, or a blank password when logging in for the first time. None of those is a universal MySQL default. MySQL creates accounts during data-directory initialization, and the initialization mode determines whether the first root credential is random or absent.

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.

Installers can also choose their own setup flow. An installer may ask you to create a password, generate one, or initialize the server in a way that leaves no password temporarily. Therefore, the correct question is not “What is the default password?” but “How was this server initialized, and which host-qualified root account am I trying to use?”

MySQL identifies an account by both a user name and a host. root@localhost, [email protected], and root@::1 can be separate accounts with different authentication settings and passwords. A password that works for one account does not automatically work for another.

Initial credentials created by each initialization mode

Initialization method Initial root state Where to get in Required next action
mysqld --initialize A random temporary password is created for root@localhost. The password is expired. Find the generated password in the server error log, then use the MySQL client with a password prompt. Run ALTER USER 'root'@'localhost' IDENTIFIED BY 'new_password'; immediately.
mysqld --initialize-insecure The initial root account has no password. Connect with mysql -u root --skip-password. Assign a strong password before doing other administration.
Installer-managed setup Depends on the installer and its answers. It may ask for a password or use one of the initialization modes above. Use the password chosen during setup, or determine the initialization mode and inspect the error log. Verify the password for the exact host-qualified account you use.

The temporary password created by the secure initialization mode is not a normal long-term credential. MySQL marks it expired, so the account must change it before ordinary administrative work can continue.

How to log in when MySQL generated a temporary password

1. Locate the server error log

During mysqld --initialize, MySQL writes the generated root password to the server error log. The exact file location depends on the server configuration and operating system; use the configured error-log destination rather than assuming a universal path. Search the log produced at initialization for the entry containing the temporary password.

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

If the initialization output was displayed in a terminal, the same password may have been visible there. Treat it as sensitive: anyone who can read the log can use the temporary credential until you replace it.

2. Connect with a password prompt

mysql -u root -p

When the client prompts, enter the temporary password exactly as recorded. Do not append the password to the command. Using -p without a value keeps the credential out of the command line, where other users or processes may be able to inspect it.

3. Replace the expired credential

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

Choose a unique password that meets your organization’s policy. The statement changes the password for root@localhost; if you intended to administer a different host-qualified account, use that account name and host explicitly.

Rank #2
MySQL Pocket Reference
  • Used Book in Good Condition

4. Verify the new login

Exit the client and reconnect with mysql -u root -p, entering the new password. A successful login confirms that the account and password you changed match the connection you are making. If the client still reports “access denied,” investigate the host part and authentication account instead of repeatedly guessing passwords.

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

How to log in after an insecure initialization

An insecure initialization intentionally creates the initial root account without a password. This is useful for controlled setup, but it is not a finished security configuration.

mysql -u root --skip-password

Once connected, set a password immediately:

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

After the statement succeeds, leave the session and reconnect with mysql -u root -p to verify the password. Do not continue operating an administrative server with the no-password account. The no-password state is an initialization condition, not a default credential that should be preserved.

How to reset a forgotten MySQL root password

If the current password is unknown and no other administrative account is available, MySQL’s generic recovery procedure is to start the server temporarily with grant-table checks disabled. This requires taking the server through a controlled stop and restart, and the exact service commands differ by operating system and installation method.

Before you begin

  • Plan a maintenance window because the server must be stopped and restarted.
  • Obtain local administrative access to the machine running MySQL.
  • Identify the normal startup method so you can remove every recovery-only option afterward.
  • Prevent untrusted users from accessing the machine during the recovery interval.

1. Stop the MySQL server

Stop the service using the service manager or startup method used by your installation. Confirm that the server process has actually stopped before continuing; starting a second instance against the same data directory can cause errors or data corruption.

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

2. Start temporarily with --skip-grant-tables

Start the server with --skip-grant-tables. Follow the platform-specific startup instructions for your installation and keep the recovery process local to the machine.

MySQL’s documentation gives this warning: “This enables anyone to connect without a password and with all privileges.” The option bypasses authentication checks, so any local user who can reach the server while it is running in this mode can obtain unrestricted database access.

The bypass also enables skip_networking, which disables remote connections during recovery. That behavior limits exposure over the network, but it does not protect against untrusted local users.

3. Connect without a password

mysql

Do not use a saved password or assume that a normal authenticated connection is available. The point of this temporary mode is that the client can connect without presenting credentials.

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

4. Reload privilege data and set the new password

Once connected, reload the grant tables before changing the account:

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

FLUSH PRIVILEGES re-enables the account-management statements needed for the reset. Replace MyNewPass with a strong secret; do not use that literal example in production.

5. Stop the recovery instance

Stop the server again using the same controlled method. Verify that the process started with --skip-grant-tables is no longer running.

6. Restart normally

Start MySQL with its ordinary configuration. Remove --skip-grant-tables and any recovery-only skip_networking override. Leaving either setting in a permanent service definition can prevent normal authentication or remote connectivity.

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

7. Test the reset

mysql -u root -p

Enter the new password. If the login succeeds, the reset is complete. If it fails, stop and check which account the client is matching rather than starting another recovery instance unnecessarily.

Why “access denied for user root” can persist after a reset

The host part is different

The account name includes both user and host. A command that connects through localhost may match root@localhost, while a connection to 127.0.0.1 can match [email protected]. IPv6 loopback connections can match root@::1. Each account can have a separate password and privileges.

If you reset root@localhost but your client is matching another host entry, the new password will appear not to work. Determine the connection endpoint and change or use the corresponding account deliberately.

Name resolution is disabled

When the server option skip_name_resolve is enabled, MySQL does not resolve host names for account matching. A connection addressed as 127.0.0.1 or ::1 may therefore not match an account defined for localhost. Create an account for the address you actually use, or connect through a host value that matches an existing account.

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.

The client is reading a different option file

Client option files can supply a user name, host, socket, or other connection setting. If an apparently correct command reaches a different server or socket, inspect the effective client settings and make the host and account explicit while troubleshooting.

The password was exposed or copied incorrectly

Use -p with no inline value and type the password at the prompt. Avoid putting a password directly in a shell command, script argument, or process list. Check for copied whitespace, keyboard-layout differences, and shell history entries if the credential was handled at a terminal.

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

Choosing the right recovery path

Situation Recommended path Can the server stay online? Main risk or limitation
The temporary password from secure initialization is available Read it from the error log, connect with mysql -u root -p, then run ALTER USER. Yes, use the normal running server. The password is expired and must be replaced before normal administration.
The data directory was initialized with --initialize-insecure Connect with mysql -u root --skip-password, then run ALTER USER. Yes, use the normal running server. The account has no password until you set one.
The password was forgotten and no administrator can log in Stop MySQL, start temporarily with --skip-grant-tables, run FLUSH PRIVILEGES and ALTER USER, then restart normally. No. A controlled outage is required. Authentication is bypassed; anyone with local access has unrestricted privileges during recovery.
The password works for one endpoint but not another Check the host-qualified account and whether skip_name_resolve is enabled. Usually yes. Changing the wrong host-specific account does not fix the account actually being used.

Security precautions after the password change

  • Confirm that the server is running without --skip-grant-tables.
  • Remove any temporary skip_networking startup override unless it is part of your intentional configuration.
  • Protect and, where appropriate, restrict access to the error log because it may contain the initial temporary password.
  • Use separate administrative and application accounts instead of placing the root password in application configuration.
  • Review host-qualified root accounts so that unused entries are not left with weak or unknown credentials.
  • Use the password prompt form, mysql -u root -p, rather than putting the password on the command line.

Optional administration tools

MySQL documents mysql_secure_installation as a utility that automates much of the initial hardening workflow. It is an optional administration path, not a source of a universal default password and not a substitute for understanding which account was initialized.

MySQL Workbench provides a graphical account-management option for administrators who prefer a user interface. The same rules still apply: select the correct host-qualified account, set a password intentionally, and avoid leaving recovery options enabled.

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.

A practical decision checklist

  1. Ask how the data directory was initialized: secure, insecure, or installer-managed.
  2. If secure initialization was used, retrieve the temporary password from the error log.
  3. If insecure initialization was used, connect with --skip-password.
  4. Set a permanent password with ALTER USER 'root'@'localhost' IDENTIFIED BY 'new_password';.
  5. If no password works, verify whether the connection is matching root@localhost, [email protected], or root@::1.
  6. If the password is forgotten and no administrator account is available, schedule downtime and use --skip-grant-tables only for the shortest possible recovery window.
  7. Restart normally, remove all bypass options, and test with a password prompt.

Common mistakes and their fixes

Mistake Why it fails Fix
Trying root or mysql as the password MySQL does not define one universal password. Determine the initialization mode and retrieve or set the actual credential.
Using the temporary password after the first login The password is intentionally expired. Run ALTER USER immediately.
Resetting root@localhost while connecting to an IP address The client may match a different host-qualified account. Use the matching host account or connect through the intended host value.
Leaving --skip-grant-tables in the service configuration Authentication remains bypassed. Remove the option and restart MySQL normally as soon as the reset is complete.
Putting the password after -p on the command line Command-line arguments can be visible to process-inspection tools and shell history. Use -p alone and enter the password at the prompt.

Bottom line

There is no default MySQL password shared by every installation. A secure initialization creates a random temporary password in the error log; an insecure initialization creates a passwordless root account; an installer may use either flow or ask you to choose a password. Set a permanent credential with ALTER USER, account for MySQL’s user-and-host naming, and reserve --skip-grant-tables for a controlled, temporary recovery when the password is genuinely unavailable.

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.

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 quests from Patch Notes

  1. How to Set Up a RedM (RDR2) Server in 2026: License Key, txAdmin and server.cfg, Step by StepBlog11min
  2. Best RedM (RDR2) Server Hosting in 2026: Comparing Four Hosts on Slots, Memory and PriceBlog10min
  3. How to Host a Mindustry Server in 2026: server-release.jar, Port 6567 and the Commands That MatterBlog7min
Recommended PC Tool
Recommended PC Tool
Crashes, No Sound, or Screen Glitches?Free driver scan
Windows Errors? Fix Them Before They SpreadFree repair scan

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.