Hosting

How to Create a Database User in cPanel: 7 Proven Easy Steps

0

How to Create a Database User in cPanel is an essential skill for beginners who manage PHP websites, WordPress installations, and MySQL or MariaDB databases. A database user allows your website application to connect to a database using a username and password.

If you are new to cPanel, database management may initially seem complicated. However, How to Create a Database User in cPanel is actually a straightforward process when you understand what each setting does.

A database user is separate from your regular cPanel account login. It has its own username, password, and database privileges. Your PHP application can use these credentials to connect to the required database.

In this guide, you will learn How to Create a Database User in cPanel, how to connect that user to a database, how to assign privileges, how to update PHP configuration, and how to troubleshoot common database connection errors.

How to Create a Database User in cPanel

What Is a Database User in cPanel?

Before learning How to Create a Database User in cPanel, it is important to understand what a database user actually means.

A database user is an account that has permission to access and work with a particular database. Your PHP application normally uses this account when it needs to read or modify information stored in MySQL or MariaDB.

For example, a PHP website might have the following database information:

Database Name: example_database
Database User: example_user
Database Host: localhost
Database Password: ********

The application uses these credentials to establish a database connection.

A database user can be given different privileges depending on what the application needs. These privileges may include SELECT, INSERT, UPDATE, and DELETE.

Learning How to Create a Database User in cPanel therefore helps you understand an important part of website hosting and PHP development.

Why Do You Need a Database User?

A PHP website usually needs a database user when it works with MySQL or MariaDB.

For example, an application might store the following information in a database:

  • User accounts
  • Website settings
  • Blog posts
  • Product information
  • Orders
  • Contact form submissions
  • Comments
  • Categories
  • Login information

Instead of allowing the application to use a server administrator account, you create a dedicated database user.

This is better for security and organization because the application’s database credentials can be managed separately.

When learning How to Create a Database User in cPanel, remember that the database, database user, and cPanel account are different things.

Database, Database User, and cPanel Account Explained

Beginners often confuse these three terms.

cPanel Account

Your cPanel account gives you access to the hosting control panel. From cPanel, you can manage files, domains, databases, email accounts, backups, and other hosting features.

Database

The database stores your application’s information.

For example:

website_database
├── users
├── products
├── orders
└── settings

Database User

The database user is the account that connects to and operates on the database according to its assigned privileges.

Understanding this difference makes How to Create a Database User in cPanel much easier.

What You Need Before Creating a Database User

Before starting How to Create a Database User in cPanel, make sure you have access to your hosting account and cPanel.

You should also know:

  • Your database name
  • The purpose of the database
  • Your website’s PHP configuration
  • Whether your server uses MySQL or MariaDB
  • The username you want to create
  • A secure password

If you are setting up a new PHP website, you may need to create both the database and database user.

If the database already exists, you only need to create the user and connect it to that database.

cPanel’s current documentation recommends using the Database Wizard when setting up your first database and user.

How to Create a Database User in cPanel Using Database Wizard

The easiest method for beginners is the cPanel Database Wizard.

The exact appearance of cPanel can vary depending on your hosting provider and cPanel version, but the overall process is similar.

Step 1: Log In to cPanel

Start by logging in to your hosting account.

Your hosting provider normally gives you a cPanel login URL. After logging in, you will see the cPanel dashboard.

Look for the Databases section.

Depending on your cPanel version, you may see an option called:

Database Wizard

Older versions may display:

MySQL Database Wizard

Current cPanel documentation identifies the newer interface as Database Wizard, while older versions used the MySQL Database Wizard name.

This is the first step in How to Create a Database User in cPanel.

Step 2: Open Database Wizard

Click Database Wizard.

The wizard is designed to help you create a database, create a database user, and assign the user’s privileges.

If you already have a database and only need to create a user, you can instead use Manage My Databases.

cPanel provides separate database management functionality for creating and managing databases and database users.

Step 3: Create a Database

If you are creating a completely new database, enter a suitable database name.

For example:

mywebsite

Your hosting provider may automatically add your cPanel username as a prefix.

You might therefore see something like:

myaccount_mywebsite

This prefix is normal on many cPanel hosting environments.

cPanel documents that database prefixing can affect the available name length.

Choose a meaningful name that helps you identify the database later.

For example:

shop
blog
portfolio
clientsite

Avoid unnecessarily complicated names.

Step 4: Create the Database User

After creating the database, the wizard asks you to create a database user.

Enter the desired username.

For example:

websiteuser

cPanel may automatically add your account prefix, resulting in something similar to:

myaccount_websiteuser

The exact username limits depend on the database type and cPanel configuration. cPanel’s documentation explains that MySQL and MariaDB username limits include the account prefix.

This is an important detail when learning How to Create a Database User in cPanel because beginners sometimes wonder why the final username looks different from the value they entered.

Step 5: Create a Strong Password

The next step is setting a password for the database user.

Use a strong, unique password.

Avoid passwords such as:

123456
password
admin123
website123

Instead, use a long password containing a mixture of characters.

For example:

V9!kR2#pLm7@xQ4

Do not use this example password for a real website.

cPanel provides a password generator and evaluates password strength when creating a database user.

Save the database password somewhere secure because your PHP application will need it.

Step 6: Create the User

After entering the username and password, click Create User.

cPanel will create the database account.

At this point, you have learned the central part of How to Create a Database User in cPanel.

However, creating the user does not necessarily mean that it has access to every database.

The user needs to be associated with the appropriate database and given suitable privileges.

Step 7: Assign Database Privileges

After creating the user, cPanel will allow you to assign privileges.

You may see options such as:

  • SELECT
  • INSERT
  • UPDATE
  • DELETE
  • CREATE
  • ALTER
  • INDEX
  • DROP
  • ALL PRIVILEGES

For many normal PHP applications, the required permissions depend on what the application does.

If you are setting up a new website and the application requires full control of its own database, you may select ALL PRIVILEGES.

However, do not automatically give excessive permissions to applications that do not require them.

cPanel’s Database Wizard lets you select the privileges you want to grant to the user.

This privilege step is one of the most important parts of How to Create a Database User in cPanel.

How to Create a Database User in cPanel for an Existing Database

Sometimes the database already exists and you only need to create a new user.

In that situation, the process is slightly different.

Open:

cPanel → Databases → Manage My Databases

Then find the section for creating a new database user.

Enter the username and password, then click Create User.

After creating the user, locate Add User To Database.

Select:

User: websiteuser
Database: website_database

Then click Add.

cPanel will display the available privileges. Select the permissions required by your application and click Make Changes.

This method is particularly useful when learning How to Create a Database User in cPanel for an existing PHP application.

How to Connect the Database User to PHP

Creating a database user is only part of the process.

Your PHP application also needs to know the database credentials.

A simple PHP application might use code similar to this:

<?php

$host = "localhost";
$dbname = "myaccount_mywebsite";
$username = "myaccount_websiteuser";
$password = "YOUR_DATABASE_PASSWORD";

$conn = new mysqli($host, $username, $password, $dbname);

if ($conn->connect_error) {
    die("Database connection failed.");
}

echo "Database connection successful.";
?>

The actual configuration will depend on your application.

Some PHP projects store database credentials in:

config.php
database.php
.env
settings.php

For example, an application using environment variables might have:

DB_HOST=localhost
DB_DATABASE=myaccount_mywebsite
DB_USERNAME=myaccount_websiteuser
DB_PASSWORD=YOUR_DATABASE_PASSWORD

Never publish your actual database password in a public Git repository or expose it through your website.

Knowing how to connect the user to PHP completes another important part of How to Create a Database User in cPanel.

How to Test the Database User

After learning How to Create a Database User in cPanel, you should test whether the credentials actually work.

One simple method is to temporarily create a PHP connection test.

For example:

<?php

$conn = new mysqli(
    "localhost",
    "myaccount_websiteuser",
    "YOUR_DATABASE_PASSWORD",
    "myaccount_mywebsite"
);

if ($conn->connect_error) {
    die("Connection failed: " . $conn->connect_error);
}

echo "Database connection successful.";
?>

If you see:

Database connection successful.

the credentials are working.

After testing, remove the test file from your server.

Do not leave database testing scripts publicly accessible because they may expose unnecessary information.

Common Errors When Creating a Database User

When learning How to Create a Database User in cPanel, beginners may encounter several common errors.

Access Denied for User

You may see an error such as:

Access denied for user 'websiteuser'

This can happen when:

  • The username is incorrect
  • The password is incorrect
  • The user is not assigned to the database
  • Required privileges were not granted
  • The database host is incorrect

Double-check all database credentials.

Unknown Database

An error such as:

Unknown database 'mywebsite'

usually means the database name in your PHP configuration does not match the actual database name.

Remember that cPanel may add your account username as a prefix.

For example, you might enter:

mywebsite

but the actual database could be:

myaccount_mywebsite

Always copy the exact database name shown in cPanel.

User Has No Privileges

If the database exists but your PHP application cannot read or modify it, check whether the user has been added to the database.

Go to:

cPanel → Manage My Databases → Add User To Database

Then select the appropriate user and database.

Password Authentication Error

If the password is incorrect, you can change the database user’s password from the database management interface.

cPanel provides a Change Password option for existing database users.

After changing the password, update the corresponding PHP configuration.

Database User Security Best Practices

Security should always be considered when learning How to Create a Database User in cPanel.

Use a Unique Password

Do not reuse your cPanel password for a database user.

Use a unique and strong password.

Avoid Sharing Database Credentials

Only give database credentials to people or applications that genuinely need them.

Use Appropriate Privileges

Grant only the privileges the application requires whenever practical.

For example, an application that only needs to read data may not need permission to drop tables.

Protect Configuration Files

If your application stores credentials in a configuration file, make sure that file is not publicly downloadable.

Do Not Store Backups in Public Directories

Avoid placing SQL backups inside directories that visitors can access through a browser.

For example, do not leave:

database-backup.sql
backup.zip
website.sql

inside a public web directory.

Should You Use phpMyAdmin to Create a Database User?

A common beginner question about How to Create a Database User in cPanel is whether phpMyAdmin should be used for this task.

For cPanel hosting, use cPanel’s Database Wizard or Manage My Databases interface to create and manage database users.

cPanel specifically warns against using phpMyAdmin to create databases or database users because cPanel needs to map those resources correctly for account management, backups, and restorations.

phpMyAdmin is useful for working with an existing database, such as viewing tables, running SQL queries, importing data, and managing records.

Database User vs cPanel User

These accounts serve different purposes.

A cPanel user manages hosting resources through the control panel.

A database user connects to MySQL or MariaDB databases.

For example:

cPanel Account
      ↓
Manage Hosting
      ↓
Database
      ↓
Database User
      ↓
PHP Application

Understanding this distinction makes How to Create a Database User in cPanel easier to remember.

Can One Database Have Multiple Users?

Yes.

A database can have multiple users with different permissions.

For example:

Database: company_database

Users:
├── website_user
├── reporting_user
└── admin_user

Each user can have different privileges depending on the application requirements.

This can be useful for separating website access, reporting, administration, and other tasks.

Can One User Access Multiple Databases?

Depending on your hosting configuration and permissions, a database user can be assigned to multiple databases.

For example:

website_user
   ├── website_database
   ├── analytics_database
   └── reporting_database

However, avoid giving a user access to databases it does not need.

Keeping database access organized is a good security practice.

How to Change a Database User Password

If you forget the password, you can change it from cPanel.

Open:

cPanel → Databases → Manage My Databases

Find the database user and choose Change Password.

Enter a new secure password and save the change.

Then update the password in your PHP application’s configuration file.

cPanel notes that it does not reveal the existing database password; if you forget it, you need to change the password.

This is another useful task to understand after learning How to Create a Database User in cPanel.

How to Delete a Database User

If a database user is no longer required, you can remove it from cPanel.

Open Manage My Databases, locate the user, and select the delete option.

Before deleting a user, make sure no active website or application is using its credentials.

Deleting the wrong user can cause your PHP application to stop connecting to its database.

Always check your configuration before removing database users.

Internal Links for Further Reading

If you are learning PHP and server management, these related tutorials can help:

  • [Internal link: How to Create a MySQL Database in cPanel]
  • [Internal link: How to Connect PHP to MySQL Database]
  • [Internal link: How to Secure a PHP Website]
  • [Internal link: How to Configure PHP on cPanel]
  • [Internal link: How to Troubleshoot MySQL Connection Errors]

These internal links can also help visitors move between related tutorials and improve your website’s overall content structure.

Useful External Resources

For the most accurate and current cPanel instructions, consult the official cPanel documentation. cPanel’s current Database Wizard documentation explains how to create databases, users, passwords, and privileges. cPanel Database Wizard Documentation

You can also review cPanel’s documentation for managing existing databases and users. cPanel Manage My Databases Documentation

For MySQL-related concepts and database administration, the official MySQL documentation is another useful reference.

Frequently Asked Questions

What is the easiest way to create a database user in cPanel?

The easiest method for beginners is the Database Wizard. It guides you through creating the database, creating the user, setting the password, and assigning privileges.

How to Create a Database User in cPanel if the database already exists?

Open Manage My Databases, create the user, and then use Add User To Database to connect the user to the existing database. After that, assign the required privileges.

Do I need a database user for a PHP website?

If your PHP website uses MySQL or MariaDB, it normally needs database credentials, including a database username and password, to connect to the database.

Can I use the same database user for multiple websites?

You can, depending on your hosting setup, but using separate database users can provide better separation and make access management easier.

Should I give the database user ALL PRIVILEGES?

It depends on the application’s requirements. For a database dedicated to a single application, ALL PRIVILEGES may be appropriate, but granting only the permissions actually needed is a better security practice when practical.

Why does cPanel add a prefix to my database username?

Many cPanel servers use account-based database prefixes to keep database names and users associated with the correct hosting account. This is why the final name may contain your cPanel username.

Database User Creation Checklist

Use this checklist when following How to Create a Database User in cPanel:

  • Log in to cPanel
  • Open Database Wizard or Manage My Databases
  • Create the database if required
  • Choose a meaningful database username
  • Create a strong password
  • Create the database user
  • Add the user to the correct database
  • Assign the required privileges
  • Copy the exact database name
  • Copy the exact database username
  • Update PHP configuration
  • Test the database connection
  • Remove temporary test files
  • Keep database credentials private
  • Review database permissions

Conclusion

Learning How to Create a Database User in cPanel is an important step for anyone working with PHP, MySQL, MariaDB, WordPress, or other database-driven websites.

The basic process is simple: log in to cPanel, open Database Wizard or Manage My Databases, create the user, set a strong password, connect the user to the correct database, and assign appropriate privileges.

Once you understand How to Create a Database User in cPanel, you can confidently configure database credentials for PHP applications and troubleshoot many common connection problems.

Remember that the database name, database username, password, and privileges must all be correct. If one of these values is incorrect, your PHP application may not be able to connect.

For beginners, the safest approach is to use cPanel’s built-in database management tools, keep credentials secure, avoid unnecessary privileges, and test the connection after setup.

With these steps, How to Create a Database User in cPanel becomes a simple and repeatable process you can use whenever you set up a new PHP website or database-driven application.

How to Migrate a PHP Website to a New Server: 7 Proven, Easy Steps

Previous article

How to Create a MySQL Database in cPanel: 7 Proven Easy Steps

Next article

Comments

Leave a reply

Your email address will not be published. Required fields are marked *