Before your website can connect to a database, you must create a database, create a user, and assign that user to the database with the correct permissions.
1. Create the Database
Log in to cPanel and open MySQL® Databases.
Under Create New Database, enter a name and click Create Database.
Note: cPanel will prefix your database name (e.g., accountname_dbname).
2. Create a Database User
Scroll to MySQL Users and create a new user with a strong password.
Do not reuse your cPanel password.
3. Assign User to Database
Under Add User To Database, select your user and database, then click Add.
4. Set Permissions
On the privileges screen, select All Privileges unless your application requires restricted access.
This step is commonly missed and will cause connection errors.
5. Save Your Credentials
You will need:
- Database Name
- Database Username
- Password
- Database Host (usually localhost) but for remote MySQL you can use any qualified domain or remote IP
Common Mistakes
- Forgetting to assign the user to the database
- Using the wrong database name (missing cPanel prefix)
- Wrong password or host
Done
Your database is now ready for your application to connect.