How to Create a MySQL Database in cPanel

Create a MySQL database and user in cPanel, then assign privileges so your application can connect and store data.

· Updated · 3,924 views

Most web applications, including WordPress, store their content in a MySQL database. cPanel lets you create a database, a database user, and link the two without using the command line.

Create the Database

  1. In cPanel, open MySQL Databases under the Databases section.
  2. Under Create New Database, type a name. cPanel adds a prefix based on your account, so the full name looks like cpuser_appdb.
  3. Click Create Database, then click Go Back.

Write down the full database name including the prefix, you will need it later.

Create a Database User

  1. Scroll to MySQL Users and find Add New User.
  2. Enter a username and use the password generator for a strong password.
  3. Click Create User and save the credentials securely.

Assign the User to the Database

A user can only access a database after it is added to it.

  1. Under Add User To Database, pick your user and database from the dropdowns.
  2. Click Add.
  3. On the privileges screen, tick ALL PRIVILEGES, then click Make Changes.

Connection Details

When your application asks for database settings, use these values:

| Setting | Value | |----------|--------------------------------| | Host | localhost | | Database | cpuser_appdb (your full name) | | Username | cpuser_dbuser (with prefix) | | Password | the one you created |

The host is almost always localhost on shared hosting, not your domain or an IP address. If a connection fails, double-check that the user was actually assigned to the database and that the prefix is included in both the database and username.

Was this article helpful?

Your feedback helps us improve our documentation.

Still Need Help?

Our support team is available 24/7 to assist you.