UnderHost
Knowledgebase Docs

Creating and managing MySQL databases in cPanel

Create MySQL or MariaDB databases and users in cPanel, assign privileges, connect applications, manage character sets, and import/export data with phpMyAdmin.

On this page

Most dynamic web applications, including WordPress, Joomla, Magento, and custom PHP apps, require a MySQL or MariaDB database. cPanel makes it easy to create databases, create users, assign permissions, and import or export data.

Create a database and user

  1. In cPanel, go to Databases -> MySQL Databases. You can also use MySQL Database Wizard for a guided workflow.
  2. Under Create New Database, enter a name and click Create Database.
  3. Under MySQL Users, create a user with a strong unique password.
  4. Under Add User to Database, select the user and database, then click Add.
  5. Choose the privileges the application needs. For most CMS installations, select All Privileges.
Use the full prefixed names

cPanel adds your account username as a prefix to database names and database users. Use the full names, such as username_dbname and username_dbuser, in your application configuration.

Connect your application

SettingValue
Database hostlocalhost for same-server cPanel applications
Database nameThe full prefixed database name
Database userThe full prefixed database username
PasswordThe password you set for the database user
Port3306 unless your application specifically says otherwise

Character sets and collations

For modern websites, use utf8mb4 when possible. It supports full Unicode, including emoji and multilingual content. A common modern collation is utf8mb4_unicode_ci or the default collation selected by your MySQL/MariaDB version.

You normally do not need to change character sets manually for WordPress or modern installers. If you are importing an older database and see garbled characters, review the export encoding and see database character set troubleshooting.

Using phpMyAdmin

phpMyAdmin is a graphical interface for browsing tables, running SQL queries, importing database dumps, exporting backups, and repairing or optimizing tables. Open it from Databases -> phpMyAdmin.

Import and export

Export: In phpMyAdmin, select your database, click Export, choose Quick for a standard SQL backup, and download the file.

Import: Select the target database, click Import, choose your .sql or .sql.gz file, and click Go. Large files may need support assistance on shared hosting or command-line import on VPS/dedicated servers.

Back up first. Importing over an existing database can overwrite current data. Export a fresh backup before importing or running SQL changes.

Troubleshooting

IssueWhat to check
Error establishing a database connectionConfirm database name, user, password, host, and user privileges.
Access denied for userReset the database user password and make sure the user is added to the correct database.
Garbled characters after importCheck source export encoding and database character set/collation.
Import too largeCompress the SQL file, split it, or contact support for shared-hosting imports.

Related: Using phpMyAdmin in cPanel-import, export, and manage databases | Database backup and restore-quick reference | UTF-8 character encoding-store international characters correctly | Fix the WordPress white screen of death | Error establishing a database connection-diagnosis and fix

Was this article helpful?

Need cPanel hosting or licensing?

Use UnderHost cPanel hosting or add cPanel/WHM to a VPS or dedicated server for familiar website, email, DNS, and database management.

Related articles

Back to cPanel