Where MySQL stores your login information
Your MySQL username and password are stored in configuration files on your server, not displayed in a control panel the way some other services show them. The location depends on how MySQL was installed and what software is using it — a WordPress site stores credentials differently than a standalone database server.
The most common places to look are your web hosting control panel (cPanel, Plesk, or similar), your process's configuration file, or the MySQL server itself if you have direct access. Each route requires different steps, and some require command-line access that not all hosting accounts provide.
Key Takeaways
- Web hosting control panels like cPanel show MySQL usernames and passwords in the database section, and you can reset the password there without needing command-line access.
- WordPress and other applications store MySQL credentials in a configuration file (wp-config.php for WordPress) that you can read through your file manager or FTP client.
- If you have SSH access to your server, you can query the MySQL server directly to see which users exist, though you cannot retrieve a forgotten password — you can only reset it.
- Resetting a MySQL password requires either control panel access, command-line access, or help from your hosting provider if you have neither.
Checking MySQL credentials in cPanel or Plesk
If your hosting account uses cPanel, log in and look for "MySQL Databases" or "Database" in the main menu. Click it, and you will see a list of databases you have created. Next to each database name is the username that accesses it — cPanel always creates a username when you create a database, and it is displayed here.
To see or reset the password, click "Change Password" next to the username. cPanel will not show you the old password (it is encrypted), but you can set a new one when ready. Write down the new password and use it to connect to the database.
Plesk works similarly: log in, go to Databases, select the database, and you will see the username. Click the username to edit it, and you can reset the password from there. Other control panels follow the same pattern — find the database section, locate the username, and look for a password reset option.
Finding credentials in WordPress configuration files
WordPress stores the MySQL username and password in a file called wp-config.php in your website's root directory. You can read this file using your hosting control panel's file manager or an FTP client like FileZilla.
Log into your file manager, navigate to the folder where WordPress is installed (usually public_html or www), and look for wp-config.php. Right-click it and select "Edit" or "View". Search the file for these lines:
define('DB_NAME', 'database_name'); — this is your database name define('DB_USER', 'username'); — this is your MySQL username define('DB_PASSWORD', 'password'); — this is your MySQL password define('DB_HOST', 'localhost'); — this is usually localhost unless your host specified otherwise
The username and password are between the single quotes. If you need to change the password, you must update it here and also reset it in your control panel or through MySQL, or WordPress will not be able to connect to the database.
Checking MySQL users via command line
If you have SSH access to your server, you can connect to MySQL directly and see which users exist. Open a terminal or SSH client and connect to your server, then run:
mysql -u root -p
This prompts you for the root password. If you do not know the root password, you cannot proceed this way — ask your hosting provider or use the control panel method instead.
Once logged in, run:
SELECT user, host FROM mysql.user;
This shows all MySQL users on the server. To see which databases a specific user can access, run:
SHOW GRANTS FOR 'username'@'localhost';
Replace 'username' with the actual username. This shows what permissions that user has, but it does not display the password — MySQL does not store passwords in a readable form.
Resetting a forgotten MySQL password
If you cannot remember the password and do not have access to your control panel or configuration files, you will need to reset it. The method depends on what access you have.
Through your control panel: log in, find the database section, locate the username, and click the password reset option. This is the fastest route if you still have control panel access.
Through command line: if you have SSH access and know the root password, you can reset any user's password by running:
ALTER USER 'username'@'localhost' IDENTIFIED BY 'newpassword';
Then run FLUSH PRIVILEGES; to explore the change. Replace 'username' and 'newpassword' with the actual values.
If you have neither control panel access nor command-line access, contact your hosting provider. They can reset the password for you, though they may ask you to verify your account ownership first.
Verifying the credentials work
Once you have the username and password, test them to make sure they are correct. If you have command-line access, run:
mysql -u username -p
Then enter the password when prompted. If you connect successfully, the credentials are correct. Type exit to disconnect.
If you do not have command-line access, you can test the credentials by trying to connect through a database management tool like phpMyAdmin (usually available in your control panel) or a desktop process like MySQL Workbench. Enter the hostname (usually localhost), username, password, and port (usually 3306), and try to connect. If it succeeds, the credentials are correct.
Frequently Asked Questions
Can I see my MySQL password if I forgot it?
No. MySQL stores passwords encrypted, so even administrators cannot retrieve the original password. You can only reset it to a new one through your control panel, command line, or by contacting your hosting provider.
Why does my WordPress site say "Error establishing a database connection"?
This usually means the username, password, or hostname in wp-config.php is wrong. Check that the credentials match what your control panel shows, and make sure the hostname is correct — it is usually localhost, but some hosts use a different server address.
What if my hosting provider will not tell me the MySQL password?
Most providers will not share the root password for security reasons, but they will reset a user password for you if you ask. You can also reset it yourself through your control panel or by reading the configuration file in WordPress or another process.
Is localhost the same as my server's IP address?
For most shared hosting accounts, yes — localhost refers to the same server your website runs on. Some hosts use a different hostname or IP address for the database server. Check your control panel or ask your provider if you are unsure.