Most web applications (WordPress, Joomla, custom PHP applications) require a MySQL database. In cPanel, you need to create three things: a database, a user, and then assign the user to the database with the appropriate privileges.
Please note: Screens and options may vary slightly depending on your cPanel version and hosting plan.
Step 1: Create the Database
- Log in to your cPanel account.
- In the Databases section, click MySQL Databases.
- Under Create New Database, enter a name for the database. cPanel will prefix it with your account username (e.g.
username_mydatabase). - Click Create Database.
Step 2: Create a Database User
- On the same MySQL Databases page, scroll down to MySQL Users.
- Under Add New User, enter a Username and a strong Password.
- Click Create User.
Step 3: Assign the User to the Database
- Scroll down to Add User To Database.
- Select the User and the Database from the dropdowns.
- Click Add.
- On the privileges page, select the permissions you want to grant. For most web applications, select ALL PRIVILEGES.
- Click Make Changes.
Finding Your Database Connection Details
Your application will need these details to connect to the database:
| Setting | Value | |---------|-------| | Database Name | username_mydatabase (as shown in cPanel) | | Database User | username_myuser (as shown in cPanel) | | Database Password | The password you set in Step 2 | | Database Host | localhost (for applications on the same server) |
Tips
- Database and user names in cPanel are always prefixed with your cPanel username and an underscore. Keep the names you enter short.
- The
localhosthostname works for applications running on the same server. For remote connections, see the Remote MySQL article. - If you're installing an application through Softaculous, the database, user, and privileges are created automatically.
- You can create multiple databases and users as needed. Each can have different privilege levels.
What Next?
- Managing Databases with phpMyAdmin — Browse, edit, and query your database.
- Enabling Remote MySQL Access — Connect to your database from another server.