Where MySQL stores your login information
Your MySQL username and password are not stored in one central place on your computer. Instead, they live in three locations depending on how you set up the database: the configuration file where you first installed MySQL, the command history from when you created user accounts, or the hosting control panel if MySQL is running on a web server.
The most common scenario is that you created a MySQL user account months ago and wrote the credentials down somewhere — or didn't write them down at all. The second most common is that your hosting provider created the account for you and sent it in an email you no longer have. Both are recoverable, but the path depends on whether you control the server itself or are renting space from a host.
Key Takeaways
- If you set up MySQL on your own computer, check the configuration file (my.cnf on Mac and Linux, my.ini on Windows) or your command history for the original credentials.
- If MySQL is hosted by a provider like GoDaddy, Bluehost, or your web host, log into the control panel (cPanel, Plesk, or similar) where the username and password are usually visible or can be reset.
- The MySQL root password is separate from any user accounts you created, and resetting it requires command-line access or hosting support.
- If you have forgotten both the username and password, you can reset the root password on your own server using safe mode, or contact your hosting provider to reset it for you.
Checking your hosting control panel
If your MySQL database is hosted by a web hosting company, the easiest place to find your username and password is the control panel they gave you access to. Log in to cPanel, Plesk, DirectAdmin, or whatever control panel your host uses — this is usually a web address like cpanel.yoursite.com or panel.yourhost.com.
Once you are logged in, look for a section called "Databases," "MySQL Databases," or "Database Management." Click into it. You will see a list of databases you own, and next to each one is the username that accesses it. Many control panels show the password in plain text, or offer a button to reset it to something new. If you cannot find the password displayed, you can usually reset it to a new one you choose, then use that new password to connect.
If you do not remember your control panel login, contact your hosting provider's support team with proof of account ownership. They can reset your control panel password, and from there you can see or reset your MySQL credentials yourself.
Locating credentials in your configuration file
If you installed MySQL directly on your own Mac, Linux, or Windows computer, the original setup process created a configuration file that may contain credentials or hints about them. On Mac and Linux, this file is usually at /etc/mysql/my.cnf or ~/.my.cnf. On Windows, it is typically at C:\ProgramData\MySQL\MySQL Server 8.0\my.ini (the version number may differ).
Open the configuration file with a text editor. Look for a section labeled [client] or [mysqldump]. If you see a line that says user=yourname or password=yourpassword, those are your credentials. However, most installations do not store the password in the config file for security reasons, so you may only find the username.
If the config file does not contain what you need, check your command history. On Mac and Linux, open Terminal and type history | grep mysql to see past commands you ran. You may see a line where you created a user account with a password visible in plain text — something like CREATE USER 'username'@'localhost' IDENTIFIED BY 'password';. On Windows, if you used Command Prompt, the history is usually not saved by default, but you can try pressing the up arrow to scroll through recent commands.
Resetting the root password on your own server
If you control the server and have lost the root password, you can reset it without knowing the old one. The process differs slightly between Mac/Linux and Windows, but both involve starting MySQL in safe mode so you can change the password without authentication.
On Mac or Linux, open Terminal and stop the MySQL service by typing sudo systemctl stop mysql (or sudo /usr/local/mysql/support-files/mysql.server stop on older systems). Then start it in safe mode with sudo mysqld_safe --skip-grant-tables &. This launches MySQL without checking passwords. Connect with mysql -u root, then run FLUSH PRIVILEGES; followed by ALTER USER 'root'@'localhost' IDENTIFIED BY 'newpassword'; (replace newpassword with what you want). Exit with exit, then restart MySQL normally with sudo systemctl start mysql.
On Windows, the process is similar but uses the Command Prompt. Stop the service by typing net stop MySQL80 (the version number may differ), then start it in safe mode with mysqld --skip-grant-tables. Open a second Command Prompt window, type mysql -u root, and run the same ALTER USER command. Restart the service with net start MySQL80 when you are done.
Finding credentials in old emails or backups
When you first set up a MySQL account or database, your hosting provider or setup wizard usually sent you a confirmation email with the username and password. Search your email inbox and spam folder for messages from your host or from any automated system that mentions "MySQL," "database," or "credentials." The email may be years old, so search back several years if needed.
If you have backups of your computer or server, you may find the credentials in backup files. Check any documents folder, desktop, or notes app for a file you might have named "passwords," "database info," or similar. You can also search backup files for the text "mysql" or the name of your database.
If you find an old password that no longer works, you can reset it through your control panel or by using the safe mode method described above. The important thing is that finding the username is usually easier than finding the password, so once you have the username, you can reset the password to something new.
What to do if your host will not help
Some hosting providers have policies against revealing passwords, even to account owners. If this happens, ask them to reset your MySQL password to a temporary one they generate, or to reset it to a password you provide. Most hosts will do this with proof of account ownership, even if they will not tell you the old password.
If your host is unresponsive or refuses to help, and you have command-line access to the server, you can reset the password yourself using the safe mode method above. If you do not have command-line access and your host will not help, you may need to migrate to a different host that provides better support.
Keeping track of credentials going forward
Once you have recovered your username and password, store them somewhere find. A password manager like Bitwarden, 1Password, or KeePass is the safest option — it encrypts your credentials and you only need to remember one master password. If you prefer not to use a password manager, write the credentials down on paper and store it in a locked drawer, or save them in an encrypted file on your computer.
Do not store credentials in a plain text file on your desktop, in an email to yourself, or in a shared document. Do not use the same password for MySQL as you use for your hosting control panel or email account. If someone gains access to one, they should not automatically have access to all of them.
Frequently Asked Questions
Can I see my MySQL password if I have already forgotten it?
Not directly — MySQL hashes passwords so they cannot be read back out. However, you can reset it to a new password through your control panel, by using safe mode on your own server, or by asking your hosting provider to reset it for you.
What is the difference between the root password and a regular user password?
The root user has permission to create databases, delete databases, and manage all user accounts. A regular user typically has permission only to read and write to one specific database. If you have lost the root password, you can reset it using safe mode. If you have lost a regular user password, you can reset it through the control panel or by logging in as root.
My hosting provider says they do not have my password on file. Is that normal?
Yes. Most hosts store only a hash of your password, not the password itself, for security reasons. They can reset it to something new, but they cannot tell you what the old one was. Ask them to set it to a temporary password they generate, or to reset it to a password you provide.
Can I reset my MySQL password without losing my data?
Yes. Resetting the password does not affect the data in your databases. The data stays exactly as it is — only the credentials to access it change.
What if I have multiple MySQL user accounts and I forgot which one I use?
Log into your control panel and look at the list of databases. Each database is assigned to one user account. If you know which database your process uses, you know which user account to focus on. If you are unsure, you can reset the password for the main user account associated with your site, or contact your host to ask which account your process is configured to use.