Skip to content

Product docsWeb hosting

Create MySQL databases and import them with phpMyAdmin

Create a database and user in cPanel or Plesk, connect your application, and import or export data with phpMyAdmin, including large dumps and collation errors.

  • Beginner
  • 15 min read
  • Updated
On this page
  1. Before you start
  2. Step 1: Create the database and its user
  3. Step 2: Connect your application
  4. Step 3: Import data with phpMyAdmin
  5. Step 4: Export data
  6. Troubleshooting
  7. Next steps

Most PHP applications, from WordPress to shops and forums, keep their data in a MySQL or MariaDB database. This guide creates one in cPanel or Plesk, connects your application to it and shows how to import and export data with phpMyAdmin.

Before you start

Step 1: Create the database and its user

cPanel

  1. Open Manage My Databases (or Database Wizard, which walks you through the same steps).
  2. Under New Database, enter a name and select Create Database.
  3. Under Add New User, create a user with a strong password (use the password generator).
  4. Under Add User to Database, choose the user and the database, select Add, then tick ALL PRIVILEGES and save.

cPanel prefixes database and user names with your account name, for example account_shop and account_shopuser. Database names can have at most 63 characters, including the prefix.

Plesk

  1. Open Databases and select Add Database.
  2. Enter the database name and choose the database server (MySQL or MariaDB).
  3. Create a database user with a strong password in the same form.
  4. Select OK. The database list shows the connection details for your application.

Step 2: Connect your application

Enter the details in your application's configuration file. For WordPress, these are the lines in wp-config.php:

PHP
define( 'DB_NAME', 'account_shop' );
define( 'DB_USER', 'account_shopuser' );
define( 'DB_PASSWORD', 'the-strong-password' );
define( 'DB_HOST', 'localhost' );

Use localhost as the host unless your panel shows another database server.

Verify: the application opens without a database error.

Step 3: Import data with phpMyAdmin

  1. Open phpMyAdmin from your panel (cPanel: phpMyAdmin; Plesk: the phpMyAdmin link next to the database).
  2. Select your database in the left column.
  3. Open the Import tab, choose your .sql file (or a compressed .sql.gz) and select Import (or Go).

The page shows the maximum file size. It is set by the PHP limits upload_max_filesize and post_max_size of your hosting account.

Verify: the tables appear in the left column and phpMyAdmin reports that the import finished successfully.

Step 4: Export data

Select the database, open the Export tab, keep the Quick method and the SQL format, and select Export (or Go). Keep the downloaded file in a safe place; for regular copies use the panel's backups as well (back up and restore your hosting account).

Troubleshooting

#1044 - Access denied for user. The user is not linked to the database or lacks privileges. Repeat the last step of Step 1.

#1046 - No database selected. Select the database in the left column before you import.

#1062 - Duplicate entry during import. The database already contains the data. Import into an empty database, or drop the existing tables first if you are sure.

Unknown collation: 'utf8mb4_0900_ai_ci'. The dump comes from MySQL 8 and the server runs MariaDB, which does not have that collation. Export again with a compatible setting, or replace utf8mb4_0900_ai_ci with utf8mb4_unicode_ci in the dump file before importing.

The file is larger than the maximum. Compress it (gzip dump.sql), split it, or ask us to help with the import. Raising the PHP upload limit (PHP version and settings) helps only within your plan's limits.

WordPress shows "Error establishing a database connection". The details in wp-config.php do not match; see fix WordPress errors.

Next steps

Frequently asked questions

Which database host do I use in my application?

Usually localhost, because the database runs on the same hosting server. If your panel shows a different database server address, use that one.

Why does my database name have a prefix?

cPanel adds your account name and an underscore to every database and user, for example account_shop. Use the full name, with the prefix, in your application.

My dump file is too big for phpMyAdmin. What now?

Compress it as .sql.gz, which phpMyAdmin imports directly, split it into smaller parts, or import it from the command line if your account has SSH access. Our team can also help with a large import.

Can I connect to the database from my own computer?

Only if your panel offers remote database access for your plan. Allow only your own IP address, and prefer an SSH tunnel where SSH is available.

Generate Password

Please confirm