WHAT'S NEW
Web Hosting & Server Basics · GuideGuides › Web Hosting & Server Basics

Databases for Site Owners: Create, Back Up and Restore

Understand what your site's database holds, then create one, export a backup and import it again from your control panel.

📶 Intermediate⏱ 10 min🗓 Updated November 17, 2026❤ 0
database.txt
// A database setup has 3 parts
database:  user1_site
user:      user1_admin
access:    ALL PRIVILEGES

// WordPress reads them from wp-config.php
// Before you start

🧰 What you need first

  • Access to your control panel
  • A recent backup

🎯 What you'll learn

  • Create a database and user
  • Export a database backup
  • Import a backup safely

🛠 Tools needed

  • MySQL Databases (cPanel)
  • phpMyAdmin
01 / Start here

What's in the database

Your site's files hold the design and code. The database holds the content: posts, pages, users, settings and comments. A WordPress site with a lost database is an empty site.

MySQL / MariaDB

The database systems most hosts use. They work the same way for site owners.

02 / Step 1

Create a database and user

  1. In cPanel, open MySQL Databases (or the Database Wizard).
  2. Create a new database. cPanel adds your account name as a prefix, like user1_site.
  3. Create a new user with a strong password. Save it in your password manager.
  4. Under Add User to Database, pick both and choose ALL PRIVILEGES.
03 / Step 2

Export a backup

  1. Open phpMyAdmin and click your database on the left.
  2. Click Export, keep Quick and SQL selected, then click Export.
  3. Store the .sql file somewhere safe.
04 / Step 3

Import a backup

Warning: Importing into a database that already has tables can overwrite them. Export a fresh backup before you import anything.

  1. In phpMyAdmin, click the database you want to fill.
  2. Click Import and choose your .sql file.
  3. Click Import at the bottom and wait for the success message.

Note: Large files may hit the upload limit. Raise it in your PHP settings, or ask your host to import it for you.

05 / Step 4

Connect your site

For WordPress, the database details live in wp-config.php:

define( 'DB_NAME', 'user1_site' );
define( 'DB_USER', 'user1_admin' );
define( 'DB_PASSWORD', 'your-strong-password' );
define( 'DB_HOST', 'localhost' );
06 / Help

Common problems

"Error establishing a database connection"

Why: The details in wp-config.php don't match, or the user isn't added to the database.
Fix: Check every value in wp-config.php and confirm the user has privileges on that database.

Import fails with a timeout or size error

Why: The file is too big for phpMyAdmin.
Fix: Compress it as .zip or .gz, raise the PHP limits, or ask your host for help.

// Recap

Key takeaways

A database needs a database, a user and permissions linking them
phpMyAdmin → Export makes a .sql backup file
Importing can overwrite data, so back up first
Your site's config file must match the database details
// What's next

Keep going

Enjoyed this guide?

Support free learning at mC0de.

PIX0
</> {} JS 01
0101 </> CSS JS HTML PIX0 const {} 1010 async mC0de function return 0101 <div> 1010 PIX0 CSS JS HTML const {} 0101 mC0de
PIX0 // WORLD OF CODE
PIX0 IS PREPARING SOMETHING AWESOME FOR YOU 0%