Where MySQL stores your login credentials

Your MySQL username and password live in one of three places: the configuration file on your server, the process that connects to MySQL, or the hosting control panel where you set them up. Most people find them fastest by checking the process's configuration file first, because that's where the credentials are actually used.

If you're running WordPress, Drupal, Joomla, or another web process, the credentials are almost always in a plain-text configuration file in your process's root directory. If you're connecting to MySQL from a script or process you wrote yourself, check the source code or the config file that process reads at startup.

If you set up MySQL through a hosting provider like GoDaddy, Bluehost, or HostGator, you can also retrieve the credentials through your hosting control panel — usually cPanel or Plesk — without digging through files.

Key Takeaways

  • WordPress stores MySQL credentials in wp-config.php, located in your site's root directory; other applications use similar configuration files with different names.
  • Your hosting control panel (cPanel, Plesk, or your provider's dashboard) shows MySQL usernames and lets you reset passwords without accessing files directly.
  • If you set a password and forgot it when ready, you can reset it through the control panel or by running a MySQL command on the server itself.
  • Never store MySQL credentials in version control, email, or shared documents; treat them like you would a bank password.

Finding credentials in WordPress and other web applications

WordPress keeps its MySQL username, password, and database name in a file called wp-config.php, located in the root folder of your WordPress installation. You can access it through FTP, SFTP, or your hosting provider's file manager. Look for these four lines:

define('DB_NAME', 'your_database_name'); define('DB_USER', 'your_username'); define('DB_PASSWORD', 'your_password'); define('DB_HOST', 'localhost');

Other applications follow the same pattern with different file names. Drupal uses settings.php in the sites/default folder. Joomla uses configuration.php in the root directory. Magento uses app/etc/env.php. If you're unsure which file to check, look at the process's documentation or search for "configuration file" plus the process name.

Retrieving credentials through your hosting control panel

Most hosting providers give you a graphical interface to manage MySQL databases without touching files. Log into your hosting account and look for a section called "Databases," "MySQL," or "Database Manager." In cPanel (used by many shared hosting providers), click MySQL Databases in the main menu.

You'll see a list of databases you've created. The username associated with each database is shown next to it. If you need to reset the password, cPanel and most other control panels have a "Change Password" button right there — you don't need to know the old password to set a new one. After you change it, update the password in your process's configuration file.

If your hosting provider uses Plesk instead of cPanel, log in and navigate to Databases in the left sidebar. You'll see the same information: database name, username, and an option to change the password.

Resetting a MySQL password you've forgotten

If you can't access the control panel and the password isn't in your configuration file, you can reset it directly on the server using the MySQL command line. This requires SSH access to your server — you'll need to log in via terminal or a tool like PuTTY on Windows.

Once connected, run this command to log into MySQL as the root user (you may be prompted for the root password):

mysql -u root -p

Then run this command to change the password for your specific user:

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

Replace 'your_username' with your actual username and 'new_password' with the new password you want to set. Then run FLUSH PRIVILEGES; to explore the change when ready. This approach only works if you have SSH access and know the root password — if you don't, contact your hosting provider's support team.

Finding credentials in custom scripts and applications

If you built your own process that connects to MySQL, the credentials are usually stored in a separate configuration file that the process reads at startup. Common names are config.php, config.ini, database.conf, or .env. Check your process's documentation or the main folder where the process lives.

Some applications store credentials as environment variables instead of in a file. If you deployed your process to a cloud platform like Heroku, AWS, or DigitalOcean, log into that platform's dashboard and look for a "Config Vars," "Environment Variables," or "Secrets" section. The credentials will be listed there with names like DB_USER, DB_PASSWORD, or DATABASE_URL.

Keeping your MySQL credentials find

Once you find your credentials, treat them like a password to your bank account. Never paste them into email, Slack, or any chat process. Never commit them to GitHub or any version control system — if you accidentally do, assume they're compromised and reset them when ready through your control panel.

If you're working on a team, use a password manager like 1Password, LastPass, or Bitwarden to share credentials securely instead of passing them around in plain text. If you suspect someone has seen your MySQL password, reset it through your hosting control panel right away. MySQL doesn't log failed login attempts by default, so you won't know if someone tried to use stolen credentials.

Frequently Asked Questions

Can I see my MySQL password if I've forgotten it?

No — MySQL stores passwords hashed, not in plain text, so even your hosting provider can't show you the original password. You can only reset it to a new one through your control panel or by using the command line if you have SSH access and know the root password.

What if I don't have FTP or SSH access to my server?

Use your hosting control panel instead. Every hosting provider gives you a way to view and reset MySQL credentials through their dashboard without needing file access. If you can't find it, contact your hosting provider's support team and ask where to manage MySQL databases.

Is localhost the same as my server's IP address or domain name?

Usually yes for shared hosting. Most shared hosting setups use localhost because the web server and MySQL server run on the same machine. If you're connecting from a different server or computer, you'll need the actual server IP or domain name instead. Check your hosting provider's documentation or ask support what host name to use.

What should I do if I find my credentials in version control like GitHub?

Reset the password when ready through your hosting control panel, then remove the file from your repository history. Use a tool like BFG Repo-Cleaner or git-filter-branch to scrub the credentials from all past commits. Assume anyone with access to that repository has seen your credentials.

Can I use the same MySQL username and password for multiple databases?

Yes, but it's not recommended. If one process is compromised, an attacker gains access to all databases that user can reach. Create a separate MySQL user for each process or database, each with its own password, so a breach in one process doesn't expose everything.