Black Friday deals are live 🔥 Up to 85% off hosting Free domain with yearly plans Biggest discount of the year — limited time
Ends in
14days 01hrs 49min 41sec

Create a MySQL database and user in cPanel

Updated 18 November 2026 2 views

Most dynamic sites (WordPress, stores, custom apps) need a database to store content, orders and users.

Steps

  1. Log in to cPanel and open MySQL Databases (or the Database Wizard).
  2. Under Create New Database, enter a name and create it.
  3. Under MySQL Users, add a user with a strong password.
  4. Under Add User To Database, pick the user and database and click Add.
  5. Tick ALL PRIVILEGES and save.
Server screen showing system information in a terminal
The database runs on the same hosting server, which is why its host is usually localhost.

Using it in your site

In your config file (such as wp-config.php or .env) use:

  • Database and user names: the full names shown in cPanel, usually prefixed with your account name and an underscore.
  • Host: localhost in most cases.

Ready-to-copy examples (replace the names and password with yours):

// wp-config.php (WordPress)
define( 'DB_NAME', 'account_dbname' );
define( 'DB_USER', 'account_dbuser' );
define( 'DB_PASSWORD', 'your-strong-password' );
define( 'DB_HOST', 'localhost' );
# .env (Laravel and most PHP frameworks)
DB_CONNECTION=mysql
DB_HOST=localhost
DB_PORT=3306
DB_DATABASE=account_dbname
DB_USERNAME=account_dbuser
DB_PASSWORD=your-strong-password

To import an existing database, use phpMyAdmin → Import.

For large databases, if SSH is enabled, importing from the command line is faster and more reliable:

# Import a .sql file over SSH (faster than phpMyAdmin for large databases)
mysql -u account_dbuser -p account_dbname < backup.sql

Was this article helpful?

Message us on Messenger Chat on WhatsApp