Glossary

How to Create a MySQL Database in cPanel Step by Step

Learn how to create a MySQL database in cPanel, add a user, grant permissions, and connect it to your application in under five minutes.

A person pointing at an open book on a desk, focusing on learning.

To create a MySQL database in cPanel, go to Databases → MySQL Databases, enter a name for your database, click Create Database, then create a user with a password and assign that user to the database with the appropriate privileges.

The whole process takes under five minutes, but following the right order — database first, user second, permissions last — is essential to avoid connection errors. This guide walks you through every step.

What You Need Before You Start

You only need two things:

  • cPanel access for your hosting account (credentials provided by your hosting company).
  • A name for the database and user that your application (WordPress, Joomla, Moodle, a custom script, etc.) will use.

Keep in mind that cPanel automatically prepends your account username to both the database name and the MySQL username. If your account is myuser and you name your database blog, the actual database name will be myuser_blog. Save this full name — you'll need it in your application's configuration file.

Step 1 — Create the MySQL Database

  1. Log in to cPanel (usually at yourdomain.com/cpanel or yourdomain.com:2083).
  2. Scroll to the Databases section and click MySQL Databases.
  3. In the Create New Database field, enter the name you want (without the prefix — cPanel adds it automatically).
  4. Click Create Database.
  5. cPanel will confirm the database was created. Note the full name it displays (prefix + name you chose).

Use descriptive, lowercase names without spaces: store, blog, crm2024. Avoid special characters — stick to letters, numbers, and underscores.

Step 2 — Create a MySQL User

A database without a user is like a safe without a key: it exists, but nothing can open it. Always create a dedicated user per application — never share credentials across different projects.

  1. On the same MySQL Databases page, scroll down to the MySQL Users section.
  2. Enter a username (cPanel will add the account prefix automatically).
  3. In the Password field, use cPanel's built-in password generator or create a strong password of at least 16 characters including letters, numbers, and symbols.
  4. Click Create User.
  5. Save the full username and password somewhere secure — you won't be able to retrieve the password from the panel later.

Step 3 — Assign the User to the Database

Creating the database and the user separately isn't enough — you must link them and define what the user is allowed to do in that database.

  1. In the Add User to Database section on the same page, select the user and the database from the dropdown menus.
  2. Click Add.
  3. The privileges screen will appear. For most CMS platforms (WordPress, Joomla, etc.), select ALL PRIVILEGES and click Make Changes.
Privilege What It Does Needed for WordPress?
SELECT Read data Yes
INSERT Add records Yes
UPDATE Modify records Yes
DELETE Remove records Yes
CREATE / DROP Create or delete tables Yes (for core updates)
ALTER Modify table structure Yes (for updates)

Step 4 — Connect Your Application to the Database

With the database, user, and permissions in place, you just need to tell your application how to connect. The required details are always the same four values:

  • Database host: on shared hosting this is almost always localhost.
  • Database name: the full name with prefix (e.g. myuser_blog).
  • Database user: the full username with prefix (e.g. myuser_wp).
  • Password: the one you set when creating the user.

In WordPress, these values go in wp-config.php. In Joomla, they're entered during the installation wizard or stored in configuration.php. For custom scripts, they typically live in a configuration file or environment variables.

How to Access the Database from phpMyAdmin

cPanel includes phpMyAdmin, a web-based interface for managing your databases visually. Access it from Databases → phpMyAdmin. From there you can import SQL files, run queries, edit table data, and export backups — no command line needed.

If you want hosting that makes all of this management straightforward, elenlace.com offers plans built for developers and web agencies, with full cPanel access included.

Common Mistakes When Creating MySQL Databases in cPanel

Even with a straightforward process, a few mistakes can cost hours of debugging. The most frequent ones are:

  • Using the name without the prefix in your config — your application needs the full name (prefix_name), not just the part you typed.
  • Forgetting to assign the user to the database — creating a user does not link it automatically. Step 3 is mandatory.
  • Not granting enough privileges — a user without CREATE permission won't be able to run database migrations during CMS updates.
  • Wrong database host — on some providers the host is an IP address or socket path, not localhost. If the connection fails, check your hosting documentation.

Find more tutorials and guides in our hosting glossary and tutorials section.

Key Takeaways

  • There are three mandatory steps: create the database, create the user, and assign the user to the database with privileges.
  • cPanel automatically adds your account prefix to both the database name and username — always use the full name in your application config.
  • For most CMS platforms, granting All Privileges to the user is both correct and necessary.
  • The database host on shared hosting is almost always localhost.
  • phpMyAdmin in cPanel lets you manage, import, and export your database without touching the command line.
  • Use strong passwords and a dedicated user per project — never share credentials between applications.

Looking for Mexican hosting that includes full cPanel, phpMyAdmin access, and Spanish-language support? elenlace.com has the plan your project needs. Check our pricing and start building today.

FAQ

How many MySQL databases can I create in cPanel?

It depends on your hosting plan. Basic shared plans typically allow between 5 and 25 databases. Unlimited or developer-focused plans usually have no hard cap. Check your current plan's specifications in your provider's documentation.

Can I import a SQL file into the new database from cPanel?

Yes. Go to Databases → phpMyAdmin, select your database in the left panel, click the Import tab, and upload your .sql or .sql.gz file. phpMyAdmin handles files up to several MB; for larger files, use the command-line import tool or ask your hosting provider's support team for assistance.

Why can't my application connect to the newly created database?

The most common causes are: using the database name without the prefix in your config, forgetting to assign the user to the database (Step 3), an incorrect password, or using a host other than localhost. Verify all four connection values one by one. If the error persists, check your PHP error log or your application's log file for a more specific error message.

Is it safe to grant "All Privileges" to the WordPress database user?

For most shared hosting sites, yes. WordPress needs broad permissions to run automatic core updates, install plugins, and create custom tables. If your environment demands tighter security — for example, on a dedicated server or VPS — you can restrict privileges to SELECT, INSERT, UPDATE, DELETE, CREATE, and ALTER, which cover normal CMS operations.

Compare providers

Other providers and guides worth comparing:

← All