Flash Sale:75% Off Hosting + Free DomainEnds in13h47m14sView Plans
Hostvento logoHostvento

Restore a User's Access to a Database

If an app cannot reach its database, a missing user permission is a common reason. This guide shows how to give access back in cPanel.

Databases2 min read15 steps

How database access works

A database is a store for your website's information. A database user is a login name and password. The user must also be linked to the database with privileges. Privileges are the actions the user is allowed to do, such as reading or changing data.

If the link or privileges are gone, the app shows errors like "Access denied" or "Error establishing a database connection". This can happen after a restore, a rename or a deletion.

Check the basics first

  • Is the user name in your app's config file correct? In cPanel the name starts with your account prefix.
  • Is the password right? You can set a new one below.
  • Is the host set to localhost?

Steps in cPanel

  1. Log in to cPanel.
  2. Open MySQL Databases.
  3. Scroll to Current Databases. Check that your database is listed and which users it shows.
  4. If the user is missing, scroll to MySQL Users. Look at Current Users. If the user does not exist, create it under Add New User.
  5. Scroll to Add User To Database.
  6. Choose the user, then the database.
  7. Click Add.
  8. Tick All Privileges and click Make Changes.

Reset the password

  1. In Current Users, find the user and click Change Password. You may need to scroll to the Change Password area depending on your cPanel theme.
  2. Enter a new strong password, or use Password Generator.
  3. Click Change Password.
  4. Put the same password in your app's config file. For WordPress this is wp-config.php.

Check that it works

  1. Reload your website.
  2. If the error remains, open phpMyAdmin and make sure the tables are present.
  3. If the tables are missing, restore a backup.

With root access (VPS)

Use these MySQL commands, replacing the names with your own:

GRANT ALL PRIVILEGES ON dbname.* TO 'dbuser'@'localhost';
FLUSH PRIVILEGES;

The first line gives the user full rights on that database. The second reloads the permissions.

Tip: Give each website its own database user. If one is ever leaked, the other sites stay safe.

Still stuck? Open a ticket at https://secure.hostvento.com/submitticket.php.

Quick recap

  • A user needs to exist and be linked to the database.
  • Use Add User To Database and tick All Privileges.
  • Reset the password if needed and update it in your app.
  • Test the site afterwards.
  • On a VPS you can use GRANT commands.