After creating a MySQL database and a database user in cPanel, you must assign the user to the database and set their privileges before any application (such as WordPress) can connect.

Steps to Assign a User to a Database

  1. Log in to your cPanel account.
  2. Navigate to the Databases section and click MySQL® Databases.
  3. Scroll down to the Add User to Database section.
  4. In the User drop-down list, select the database user you want to assign.
  5. In the Database drop-down list, select the target database.
  6. Click the Add button.
  7. You will be taken to the Privileges page. Check the boxes for the permissions this user should have:
    • ALL PRIVILEGES – Grants full access. Recommended for most applications (WordPress, Joomla, etc.).
    • Alternatively, select only the specific privileges needed (SELECT, INSERT, UPDATE, DELETE, CREATE, ALTER, INDEX, etc.) for tighter security.
  8. Click Make Changes.
  9. A confirmation message will appear confirming the user has been added to the database with the selected privileges.

Important Notes

  • Both the database user and the database must already exist before you can link them. Create them in the Create New Database and Add New User sections of the same page.
  • cPanel prefixes database and usernames with your cPanel username followed by an underscore (e.g. youruser_dbname). Use the full prefixed names in your application’s configuration file.
  • Most web applications require ALL PRIVILEGES to function correctly.

Troubleshooting

  • “Access denied” in your application: Verify that the user is assigned to the correct database, has the necessary privileges, and that the password in your application’s config matches the database user’s password.
  • User or database not appearing in the drop-down: Make sure you are selecting from the correct cPanel account. Users and databases cannot be shared across different cPanel accounts.
  • Need to change privileges later: You can update privileges at any time from MySQL® DatabasesCurrent Databases → click the user name next to the relevant database.
Was this answer helpful? 0 Users Found This Useful (0 Votes)