Most websites and applications — WordPress, Joomla, Laravel, custom PHP apps — require a MySQL database to store content, user data, and settings. This guide walks you through creating a database, a database user, and linking them together in cPanel.
What You'll Create
| Component | Purpose |
|---|---|
| Database | The container that stores your website's data (tables, rows, columns) |
| Database User | The account used to connect to and interact with the database |
| Privileges | Permissions that define what the user can do (read, write, delete, etc.) |
Steps
Step 1: Log in to cPanel
Navigate to yourdomain.com/cpanel or log in via the Cynet client area at manage.cynet.com.my → My Services → Web Hosting → Manage → cPanel Login.
Step 2: Open MySQL Databases
In the cPanel dashboard, scroll to the Databases section and click MySQL Databases.
Step 3: Create a New Database
- Under Create New Database, enter a name for your database
cpanelusermydb) - Keep the name short and descriptive (e.g., wordpress, shop, app)
- Click Create Database
- Click Go Back to return to the MySQL Databases page
Step 4: Create a Database User
- Scroll down to MySQL Users → Add New User
- Enter a Username — this is also prefixed with your cPanel username
- Enter a Password — click Password Generator to create a strong, random password
- Save the generated password — you'll need it when configuring your application
- Click Create User
- Click Go Back
Important: The database user password is separate from your cPanel password. Use a unique password for each database user.
Step 5: Assign the User to the Database
- Scroll down to Add User To Database
- Select the User you just created from the dropdown
- Select the Database you just created from the dropdown
- Click Add
Step 6: Set Privileges
- On the privileges page, check ALL PRIVILEGES to grant full access
- Click Make Changes
For most websites and applications, All Privileges is the correct choice. If you need restricted access for security (e.g., a read-only user), select only specific privileges.
Step 7: Done
Your database is ready. Note down these details — you'll need them when configuring your website or application:
| Setting | Value |
|---|---|
| Database Name | cpaneluseryourdbname (full name including prefix) |
| Database User | cpaneluseryourusername (full name including prefix) |
| Database Password | The password you set in Step 4 |
| Database Host | localhost |
Using the Database in Your Application
WordPress (wp-config.php)
When installing WordPress manually, enter these values in wp-config.php:
define('DBNAME', 'cpaneluseryourdbname');
define('DBUSER', 'cpaneluseryourusername');
define('DBPASSWORD', 'yourdatabasepassword');
define('DBHOST', 'localhost');
Tip: If you install WordPress via Softaculous or WP Toolkit, the database is created automatically — you don't need to do this manually.
PHP Application
Connect to the database using PDO or MySQLi:
$host = 'localhost';
$dbname = 'cpaneluseryourdbname';
$user = 'cpaneluseryourusername';
$pass = 'yourdatabasepassword';
$pdo = new PDO("mysql:host=$host;dbname=$dbname;charset=utf8mb4", $user, $pass);
Laravel (.env)
DBCONNECTION=mysql
DBHOST=localhost
DBPORT=3306
DBDATABASE=cpaneluseryourdbname
DBUSERNAME=cpaneluseryourusername
DBPASSWORD=yourdatabasepassword
Managing Your Database with phpMyAdmin
After creating the database, you can manage it (create tables, import data, run queries) using phpMyAdmin:
- Go to cPanel → Databases → phpMyAdmin
- Select your database from the left sidebar
- From here you can:
.sql file to populate the database - Export the database as a backup - Create tables and manage structure - Run SQL queries directly - Browse and edit data
Importing an Existing Database
If you have a .sql database file to import (e.g., from a migration or backup):
- Open phpMyAdmin in cPanel
- Select the target database from the left sidebar
- Click the Import tab
- Click Choose File and select your
.sqlfile - Leave the default settings (Format: SQL)
- Click Go
Upload limit: phpMyAdmin typically allows files up to 50–100 MB. For larger databases, upload the.sqlfile via FTP and import via SSH:mysql -u username -p databasename < file.sql
Deleting a Database
If you no longer need a database:
- Go to cPanel → MySQL Databases
- Scroll to Current Databases
- Click Delete next to the database you want to remove
- Confirm the deletion
Warning: Deleting a database permanently removes all data. Create a backup first if you might need the data later.
Troubleshooting
"Error establishing a database connection"
- Verify the database name, username, and password in your application's configuration file match exactly what's in cPanel (including the prefix)
- Confirm the user is assigned to the database (Step 5)
- Ensure the database host is set to
localhost
"Access denied for user"
- The user may not have been assigned to the database — go to MySQL Databases → Add User To Database
- The password may be incorrect — reset it in MySQL Databases → Change Password
- Privileges may not be set — reassign the user with All Privileges
Database not showing in phpMyAdmin
- The database user may not have privileges — reassign the user to the database
- Try logging out and back in to cPanel to refresh the session
- Verify the database exists under Current Databases on the MySQL Databases page
"Can't create database — quota exceeded"
- Your hosting plan has a maximum number of databases. Check your plan limits in the Cynet client area
- Delete unused databases to make room, or upgrade your plan