If you've forgotten a MySQL database user's password, or you want to rotate it for security reasons, you can reset it directly from your hosting control panel. The process takes a minute, but you also need to update any file on your website that stores the old password, otherwise your site will stop connecting to the database.
Before you start
Changing a database user's password does not automatically update the sites or scripts that use it. Most CMS platforms and custom applications store the database password in a single configuration file, so plan to edit that file right after you reset the password.
If the database is connected to a live WordPress site, changing the password without also updating wp-config.php will immediately break the site with a database connection error.
How to reset the password
In cPanel
- Log in to cPanel and open MySQL Databases under the Databases section.
- Scroll down to the Current Users list and find the username you want to update.
- Click Change Password next to that user.
- Enter a new strong password, or click Password Generator to create one, then confirm it.
- Click Change Password to save the new password.
In DirectAdmin
- Log in to DirectAdmin and open MySQL Management.
- Click on the database that the user belongs to.
- Find the user in the list and click Modify next to their name.
- Enter and confirm the new password.
- Click Save or Modify User to apply the change.
Update your website's configuration
Once the password is changed, update it wherever your site stores its database credentials:
- WordPress: edit wp-config.php and update the DB_PASSWORD value.
- Other custom PHP applications: check the database connection file, often named config.php, database.php, or a .env file.
- Any desktop tool or scheduled script that connects directly to the database, such as a reporting tool or an import job.
You can edit these files using the File Manager in cPanel or DirectAdmin, or by connecting via FTP.
Use a different, strong password from any other account on your hosting, and avoid reusing a password you've used elsewhere. A password manager or the panel's built in generator is the safest way to create one.
For help creating a new database and user from scratch, see How to Create a MySQL Database and Database User.