For many modern websites, especially those built with content management systems like WordPress, a database is a fundamental component. It's where all your website's dynamic content – posts, pages, user information, settings, and more – is stored and organised.
This guide will walk you through the complete process of creating a MySQL database in cPanel, including setting up a dedicated user and assigning the necessary privileges. This ensures your website has a secure and functional database to operate with.
What You'll Need:
Before you begin, make sure you have the following:
- Access to your cPanel account via your EncodeDotHost customer portal.
- A chosen name for your new database (e.g.,
mywebsite_db). - A chosen username for your database (e.g.,
mywebsite_user). - A strong, secure password for your database user.
Step 1: Create the New Database
Your first step is to create the database itself within cPanel.
- Log in to your cPanel account.
- In the "Databases" section, click on the "MySQL Databases" icon. You'll see an icon that typically looks like a database cylinder.

- Under the "Create New Database" section, enter a name for your new database in the "New Database:" field.
- Note: cPanel automatically prefixes your database name with your cPanel username and an underscore (e.g., if your cPanel username is
exampleuserand you entermydb, the full database name will beexampleuser_mydb).
- Note: cPanel automatically prefixes your database name with your cPanel username and an underscore (e.g., if your cPanel username is
- Click the "Create Database" button.

- You will see a success message confirming the database has been added. Click "Go Back".
Step 2: Create a New Database User
For security and functionality, it's essential to create a dedicated user for your database. You should never use your cPanel login details for database access.
- On the same "MySQL Databases" page, scroll down to the "MySQL Users" section.
- Under "Add New User", enter a Username for your database user.
- Note: Similar to databases, cPanel will prefix your username (e.g.,
exampleuser_myuser).
- Note: Similar to databases, cPanel will prefix your username (e.g.,
- Enter a strong password in the "Password" field and re-enter it in the "Password (Again)" field. We highly recommend using the "Password Generator" for a secure password.
- Click the "Create User" button.
- You will see a success message. Click "Go Back".
Step 3: Add the User to the Database and Assign Privileges
Now you need to connect your newly created database and user, granting the user permissions to access and manage the database.
- On the "MySQL Databases" page, scroll down to the "Add User To Database" section.
- From the "User" dropdown menu, select the database user you just created (e.g.,
exampleuser_myuser). - From the "Database" dropdown menu, select the database you created in Step 1 (e.g.,
exampleuser_mydb). - Click the "Add" button.
- On the next screen, "Manage User Privileges", check the box next to "ALL PRIVILEGES". This grants the user full control over the database, which is typically required for most web applications.
- Click the "Make Changes" button.
- You will see a success message confirming the privileges have been saved.
Step 4: Note Down Your Database Details
It's crucial to record these details securely, as your website application (e.g., WordPress) will need them to connect to the database.
- Database Name: (e.g.,
exampleuser_mydb) - Database Username: (e.g.,
exampleuser_myuser) - Database Password: (the strong password you generated/set in Step 2)
- Database Host: This is almost always
localhost.
Security Tip: Never share your database credentials publicly or embed them directly in client-side code. Always store them in secure configuration files on your server.
Troubleshooting Tips:
- "Error creating database/user": Double-check for typos or if a database/user with that name already exists.
- Website connection issues: If your website can't connect to the database, ensure the database name, username, and password in your website's configuration file (e.g.,
wp-config.phpfor WordPress) exactly match the details you noted down. Also, confirm the database host islocalhost. - Password strength: Always use a strong, unique password. Weak passwords can lead to security vulnerabilities.
- Still having trouble? Contact EncodeDotHost support with details of the issue and any error messages you're receiving, and they'll be happy to assist further.
By following these steps, you've successfully created and configured a MySQL database and user in cPanel, ready for your website application to use!