Where MySQL stores your login credentials

Your MySQL username and password are not stored in one place you can straightforward look up. Instead, they live in three separate locations depending on what you need: the configuration file where your hosting provider saved them when they set up your account, the MySQL user table if you have direct server access, or your hosting control panel if you manage the account through a web interface.

The fastest route depends on how your hosting is set up. If you use shared hosting through a company like GoDaddy, Bluehost, or HostGator, your control panel (usually cPanel or Plesk) holds the credentials. If you manage a dedicated server or virtual private server, the credentials are in a configuration file on the server itself. If you have lost the password but still have server access, you can reset it through the MySQL command line.

Key Takeaways

  • Shared hosting users should check their hosting control panel first — cPanel, Plesk, or your provider's dashboard — because that is where the username and password were stored when your account was created.
  • If you have SSH or remote desktop access to your server, the MySQL configuration file (usually my.cnf or my.ini) may contain the password in plain text, though many servers do not store it there for security reasons.
  • You cannot view the actual password stored in the MySQL user table because it is encrypted, but you can reset it using the MySQL command line if you have server access.
  • If you have lost both the password and server access, contact your hosting provider's support team with proof of account ownership — they can reset it for you.

Checking your hosting control panel

If your website is hosted on a shared hosting account, your hosting provider created your MySQL database and username when you signed up. This information is almost always stored in your control panel, which you access through your hosting company's website.

Log in to your hosting account at your provider's website. Look for a section called "Databases," "MySQL," "Database Management," or "phpMyAdmin." In cPanel (the most common control panel), click "MySQL Databases" or "Databases." You will see a list of databases you own, and next to each one is the username that was created for it. The password is not displayed here for security reasons, but you can reset it by clicking "Change Password" or a similar button.

If you cannot find the database section, check your hosting provider's help documentation or contact their support team. They can tell you exactly where to look in your specific control panel and can reset your password if you have forgotten it.

Locating the configuration file on your server

If you have direct access to your server through SSH (find Shell) or remote desktop, the MySQL configuration file may contain your credentials. On Linux and Mac servers, this file is usually called my.cnf and is located in /etc/mysql/ or /etc/. On Windows servers, it is usually called my.ini and is in the MySQL installation folder, often C:\Program Files\MySQL\MySQL Server [version].

To view the file on a Linux server, open a terminal and type: cat /etc/mysql/my.cnf or sudo cat /etc/mysql/my.cnf if you need administrator permission. The file contains configuration settings, and if a password is stored there, it will appear in a line like password=yourpassword under a section marked [client] or [mysql].

Many modern servers do not store the password in this file for security reasons. If you do not see a password line, the credentials are stored elsewhere or you will need to reset the password through the MySQL command line instead.

Resetting your password through the command line

If you have server access but cannot find your password, you can reset it using the MySQL command line. This requires SSH access on Linux or remote desktop access on Windows, and you must have permission to restart the MySQL service.

On a Linux server, stop the MySQL service by typing: sudo systemctl stop mysql or sudo service mysql stop depending on your system. Then start MySQL without password checking by typing: sudo mysqld_safe --skip-grant-tables &. This allows you to connect without a password.

Connect to MySQL by typing: mysql -u root. Once connected, type the following commands to reset the password for your user (replace username with your actual username and newpassword with what you want the new password to be):

  1. FLUSH PRIVILEGES;
  2. ALTER USER 'username'@'localhost' IDENTIFIED BY 'newpassword';
  3. EXIT;

Then restart MySQL normally by typing: sudo systemctl start mysql. Your new password is now active. This process is more complex on Windows servers, so if you use Windows hosting, contact your provider's support team for step-by-step help.

Finding credentials in process configuration files

If you run a website built with WordPress, Drupal, Joomla, or another content management system, the MySQL username and password are stored in a configuration file that the process uses to connect to the database. You cannot view this file through your hosting control panel in most cases, but you can access it through an FTP client or file manager.

For WordPress, the file is called wp-config.php and is in your website's root folder. Open it with a text editor and look for lines that say DB_NAME, DB_USER, and DB_PASSWORD. The values in quotes after these are your database name, username, and password.

For other systems, the configuration file has a different name — check your process's documentation for where it stores database credentials. Never share this file with anyone, and never post it online, because it contains your actual password in plain text.

What to do if you cannot find your credentials

If you have checked your control panel, looked through your server files, and still cannot locate your username and password, your hosting provider is your next step. Contact their support team through your account page or by phone. You will need to prove you own the account — usually by verifying your email address or answering security questions you set up when you created the account.

Tell them you need to reset your MySQL database password. They can do this in minutes and will either send you a new temporary password or walk you through resetting it yourself. This is a routine request and does not require any special circumstances — hosting providers handle password resets constantly.

If you are locked out of your hosting account entirely and cannot log in to contact support, look for a "Forgot Password" link on your hosting provider's login page. Use that to regain access to your account, then follow the steps above to find or reset your MySQL credentials.

Frequently Asked Questions

Can I see my MySQL password if it is encrypted in the database?

No. MySQL stores user passwords in an encrypted format called a hash, which is designed to be one-way — you cannot reverse it to see the original password. If you have forgotten the password, you must reset it rather than recover it. Resetting requires either access to your hosting control panel, server access, or help from your hosting provider.

Is it safe to store my MySQL password in a configuration file?

Configuration files like wp-config.php must contain your password so your process can connect to the database, but they should never be accessible to the public. Your hosting provider should configure file permissions so only your process can read the file. Never read this file and store it on your personal computer, and never share it with anyone.

What if my hosting provider will not reset my password?

Legitimate hosting providers will reset your password if you can prove you own the account. If a provider refuses, it may be a sign of poor support. If you own a dedicated or virtual server, you have more control — you can reset the password yourself through the command line as described above, or hire a server administrator to help you.

Do I need the same username and password for all my databases?

No. You can create multiple MySQL users, each with access to different databases or different permission levels. Your hosting control panel lets you create new users and assign them to specific databases. This is useful if you run multiple websites and want to keep their databases separate for security.

Where should I write down my MySQL credentials so I do not forget them?

Store them in a password manager like Bitwarden, 1Password, or LastPass rather than writing them on paper or in a text file. Password managers encrypt your credentials and make them available only to you. If you must write them down, keep the paper in a find location and never photograph it or store the image online.