In short
To create a database in cPanel, open MySQL Database Wizard under Databases, name the database, create a user with a strong password and grant that user ALL PRIVILEGES. cPanel adds your account username as a prefix to both the database and user names. In your app, use localhost as the host, port 3306, and the full prefixed database name, username and password.
In this guide
- Database, user and privileges: three separate things
- Before you start: your plan's database limit
- Step-by-step: create a database with MySQL Database Wizard
- Using the MySQL Databases page instead of the wizard
- Adding the connection details to WordPress wp-config.php
- Adding the connection details to a Laravel .env file
- Do you need Remote MySQL?
- Common errors and how to fix them
- Four security rules
- How many databases will you need?
- Next step
The fastest way to create a database in cPanel is the MySQL Database Wizard. In four screens it creates the database, sets up a user, grants that user privileges and gives you everything you need to connect. This guide walks through each screen, then shows how to add those details to WordPress's wp-config.php file and Laravel's .env file.
Database, user and privileges: three separate things
In MySQL (most cPanel servers run MariaDB, which is MySQL-compatible), databases and users are independent objects. Creating a database does not automatically decide who can access it.
- Database: The container that holds your site's tables (posts, products, members, orders).
- User: The identity your application uses to connect to the database; it has a username and a password.
- Privilege: Defines which operations a user can perform on a given database, such as reading (SELECT), writing (INSERT, UPDATE, DELETE) or creating tables (CREATE).
cPanel adds your account username and an underscore to the front of every database name and database username. If your cPanel username is firma, a database you name shop is created as firma_shop. Always use this full name in your application; leaving out the prefix is the most common cause of connection errors.
Before you start: your plan's database limit
Every hosting plan limits how many databases you can create. On Sunucu Atlas cPanel web hosting plans, the limit is 2 on the entry plan SA-CP-1, 10 on SA-CP-3 and unlimited on SA-CP-6. A single WordPress site usually needs one database, but the count grows quickly once you add a test copy, a second site or a separate app. If you plan to run several projects, the SA-CP-3 hosting plan with 10 databases and 2 addon domains is a comfortable starting point.
Step-by-step: create a database with MySQL Database Wizard
After logging in to cPanel, click the MySQL Database Wizard icon in the Databases section. You can also find it by typing "wizard" in the search box.
Step 1: Create the database
- Enter a short, meaningful name in the New Database field, such as
wporshop. The prefix is already shown to the left of the field, so you only type the last part. - Use only lowercase letters, numbers and underscores. Avoid spaces and special or accented characters.
- Click Next Step.
Step 2: Create the database user
- Enter a short name in the Username field, such as
wpuser. The total length including the prefix is limited, so keep it short. - Use the Password Generator button to create a random password of at least 16 characters and save it in a password manager. You cannot view this password in cPanel later; you can only change it.
- Click Create User.
Step 3: Grant the user privileges
- On the next screen, check ALL PRIVILEGES. WordPress, WooCommerce, Laravel and similar apps create and modify tables during installation and updates, so they need full privileges.
- Click Make Changes.
If you are only connecting a reporting tool or an external dashboard, it is safer to create a separate user and grant it only the SELECT privilege.
Step 4: Note the connection details
The final screen confirms that the user was added to the database. At this point you have everything you need to connect:
| Setting | Example value | Notes |
|---|---|---|
| Host | localhost | When the app runs on the same hosting account |
| Port | 3306 | Standard MySQL/MariaDB port |
| Database name | firma_wp | Full name including the prefix |
| Username | firma_wpuser | Full name including the prefix |
| Password | (the password you saved) | Case-sensitive |
Using the MySQL Databases page instead of the wizard
The MySQL Databases page in the same section does everything the wizard does on a single screen, and it is where you handle ongoing management:
- Add User To Database: Attaches an existing user to another database and sets its privileges.
- Current Users: Change a user's password or delete a user.
- Modify Databases: Check and repair corrupted tables with Check Database and Repair Database.
- Current Databases: Rename or delete a database and see each database's disk usage.
If you change a password here, update your application's configuration file at the same time; otherwise the site will immediately show a connection error.
Adding the connection details to WordPress wp-config.php
If you are installing WordPress manually or migrating it from another server, open the wp-config.php file in the site's root directory with cPanel File Manager and edit these lines:
define( 'DB_NAME', 'firma_wp' );
define( 'DB_USER', 'firma_wpuser' );
define( 'DB_PASSWORD', 'BurayaParolaniz' );
define( 'DB_HOST', 'localhost' );
define( 'DB_CHARSET', 'utf8mb4' );
define( 'DB_COLLATE', '' );If the password contains a single quote ('), escape it with a backslash (\') or generate a new password without single quotes. Keeping DB_CHARSET set to utf8mb4 ensures that accented and non-Latin characters and emoji are stored correctly. If you installed WordPress in one click with WP Toolkit, creating the database and filling in this file are all done automatically.
Adding the connection details to a Laravel .env file
In Laravel projects, database settings live in the .env file in the project root:
DB_CONNECTION=mysql
DB_HOST=localhost
DB_PORT=3306
DB_DATABASE=firma_laravel
DB_USERNAME=firma_lvuser
DB_PASSWORD="Parola#Ornek2024"If the password contains characters such as #, spaces or $, wrap the value in double quotes; otherwise everything after # is read as a comment and the password is sent incomplete. After saving the file, clear the cached configuration and create the tables:
php artisan config:clear
php artisan migrate --forceThese commands require terminal access. Laravel hosting plans come with Terminal/SSH access through cPanel, Composer and Git, so you can run artisan commands directly on the server. If you are uploading the project for the first time, the guide to deploying a Laravel project on cPanel hosting explains the directory structure and the public folder setup step by step.
Do you need Remote MySQL?
If your site and database are on the same hosting account, you do not need remote access; localhost is the fastest and most secure option. If you need to connect from a desktop database tool or another server, add only your own static IP address on the Remote MySQL page in cPanel. Adding % (any host) to the access list exposes your database to the entire internet, so avoid it.
Common errors and how to fix them
Access denied for user 'firma_wpuser'@'localhost': The password is wrong or the user has not been added to the database. Add the user and grant privileges under Add User To Database on the MySQL Databases page, and reset the password if needed.Unknown database 'wp': The prefix is missing. Enter the database name in thefirma_wpformat.- "Error establishing a database connection" in WordPress: Besides the two causes above, table corruption or resource limits can also trigger it; see the database connection error troubleshooting guide for every scenario.
SQLSTATE[HY000] [2002]in Laravel: Try settingDB_HOSTtolocalhostinstead of127.0.0.1and runphp artisan config:clear.
Four security rules
- Give each application its own database and its own user. If one site is compromised, the others are not affected.
- Use long, unguessable passwords; never reuse your cPanel account password for a database.
- Never push
.envorwp-config.phpfiles to a public Git repository. - Delete databases and users you no longer use; it frees up your limit and shrinks the attack surface.
How many databases will you need?
Estimating your database needs correctly when choosing a plan saves you from having to upgrade later. The list below is a guideline for common scenarios, not a strict rule:
- Single WordPress site: 1 database. Plugins usually create their own tables in the same database.
- WordPress plus a staging copy: 2 databases. A separate database is essential so the test site cannot damage live data.
- Laravel project: At least 1 database; if you run tests on the server, a separate test database is recommended.
- Agency or multiple sites: At least 1 per client site, and usually 2 once staging environments are included.
- Additional apps such as a forum, CRM or help desk: A separate database and a separate user for each.
You can see how much disk space each database uses on the MySQL Databases page in cPanel. Database size counts toward your plan's total disk quota; regularly cleaning up large order and log tables protects both disk space and query speed.
Next step
Once your database is ready, you can move on to the guide to importing and exporting with phpMyAdmin to bring in an existing site's data. If you do not have a hosting account yet, choose one of the Sunucu Atlas web hosting plans, running on LiteSpeed and NVMe storage in an Istanbul data center, with a database limit that fits your number of projects. For projects that need Laravel, Composer and a terminal, the SA-DEV-1 Laravel hosting plan is built for exactly this workflow.
Frequently asked questions
Why does cPanel add my username to the front of the database name?
cPanel automatically adds your account username and an underscore as a prefix so database names from different accounts on the same server never clash. You need to use the full prefixed name in your application.
Which privileges should I give the database user?
Apps like WordPress, WooCommerce and Laravel need ALL PRIVILEGES because they create and modify tables during installation and updates. For read-only tools, create a separate user with only the SELECT privilege.
What should I enter for DB_HOST?
If the application and database are on the same cPanel account, enter localhost. The standard port is 3306, and you usually do not need to specify it separately.
I forgot my database user's password. What should I do?
cPanel does not show the password, but you can set a new one under Current Users on the MySQL Databases page. Then update the password in your wp-config.php or .env file as well.
Can I connect one user to more than one database?
Yes, you can add the same user to multiple databases under Add User To Database. For security, however, using a separate user for each application is recommended.