How to Import and Export MySQL Databases

Whether you're migrating to Faciotech, moving between servers, or managing development environments, knowing how to import and export databases is essential. This guide covers all the methods available.

Exporting a Database

Exporting creates a copy of your database that can be saved, transferred, or imported elsewhere.

Export via phpMyAdmin

  1. Log into cPanel and open phpMyAdmin
  2. Click on your database name in the left panel
  3. Click the Export tab
  4. Select export method:
    • Quick - Exports entire database with default settings
    • Custom - Choose specific tables and options
  5. Format should be SQL
  6. Click Go to download

Custom Export Options

When using Custom export, consider these options:

  • Tables - Select specific tables or export all
  • Add DROP TABLE - Useful when replacing existing database
  • Add CREATE DATABASE - Include statement to create the database
  • Compression - gzip or zip for large databases
  • Character set - Use UTF-8 for compatibility

Export Specific Tables Only

  1. In phpMyAdmin, click your database
  2. Check the boxes next to tables you want to export
  3. At the bottom, select Export from the dropdown
  4. Click Go

Importing a Database

Before You Import

Prepare for the import:

  1. Create an empty database in cPanel if one doesn't exist
  2. Create a database user and assign it to the database
  3. Backup existing data if importing to a database with content
  4. Check file size - phpMyAdmin has upload limits (usually 50MB-500MB)

Import via phpMyAdmin

  1. Open phpMyAdmin in cPanel
  2. Select the target database from the left sidebar
  3. Click the Import tab
  4. Click Choose File and select your .sql file
  5. Settings to check:
    • Character set: utf-8 (recommended)
    • Format: SQL
  6. Click Go

Import Large Databases

For databases larger than the phpMyAdmin upload limit:

Method 1: Upload via File Manager

  1. Upload your .sql file to your hosting account using File Manager
  2. In phpMyAdmin, use the Import tab
  3. Instead of uploading, enter the server path to the file

Method 2: SSH Command Line

mysql -u username -p database_name < backup_file.sql

Method 3: Split the SQL File

Use a tool like BigDump or split the SQL file into smaller parts and import sequentially.

Migrating a Website Database

When moving a website to Faciotech:

  1. Export from old host - Use phpMyAdmin or command line
  2. Create database at Faciotech - Via cPanel MySQL Databases
  3. Import the database - Via phpMyAdmin
  4. Update configuration - Edit your application's config file with new database credentials

WordPress wp-config.php Example

define('DB_NAME', 'yourusername_dbname');
define('DB_USER', 'yourusername_dbuser');
define('DB_PASSWORD', 'your_secure_password');
define('DB_HOST', 'localhost');

Exporting from Different Platforms

From WordPress (via Plugin)

  1. Install the All-in-One WP Migration plugin
  2. Go to All-in-One WP MigrationExport
  3. Choose File to download a complete backup

From cPanel at Another Host

  1. Log into cPanel at your current host
  2. Go to phpMyAdmin
  3. Select database and click Export
  4. Choose Custom and enable Add DROP TABLE
  5. Download the SQL file

Common Import/Export Issues

IssueSolution
File too large to uploadUse SSH import or split the file
Timeout during importImport in smaller batches
Character encoding errorsEnsure UTF-8 encoding on both export and import
Table already existsUse DROP TABLE option or clear database first
Foreign key constraintsDisable foreign key checks during import
Unknown collationEdit SQL file to use supported collation (utf8mb4_general_ci)

Tips for Successful Transfers

  • Always backup first - Before any import, backup existing data
  • Check PHP/MySQL versions - Ensure compatibility between old and new servers
  • Update URLs in database - For WordPress, use Search-Replace-DB tool
  • Test after import - Verify your website works correctly
  • Keep the original export - Save it until migration is fully verified

Need Assistance?

Migrating to Faciotech? Our support team can help with database imports. Submit a ticket with your SQL file and we'll assist you.

Was dit antwoord nuttig? 0 gebruikers vonden dit artikel nuttig (0 Stemmen)