Development and databases

phpMyAdmin: manage, export and import databases

Reviewed on 4 min read phpMyAdmin

phpMyAdmin is the web tool for managing MySQL databases. You will find it in cPanel > Databases > phpMyAdmin and it lets you do everything with databases that already exist.

Creating, deleting or renaming a database is always done from cPanel > Manage My Databases (formerly MySQL® Databases). If you try it from phpMyAdmin, it will be refused.

Opening phpMyAdmin from cPanel

What you can do

When you select a database in the left-hand column you can:

  • Create, empty, modify or drop tables.
  • View, create, edit and delete records (each table's Browse tab).
  • Search for text in all tables at once (the database's Search tab).
  • Run SQL queries (SQL tab).
  • Import and export.
  • Copy a database or a table to another one (Operations tab).
  • Create triggers and events.

Database open in phpMyAdmin with its tables and tabs

If you do not know which database your website uses, look at its configuration file: in WordPress it is DB_NAME in wp-config.php.

Be careful with two similar buttons: Empty deletes all the records in the table and Drop deletes the whole table. Neither can be undone.

Export a database

Select the database and open the Export tab. You will get a point-in-time copy in a file, in the format you choose (usually SQL).

phpMyAdmin's Export tab

There are two methods:

  • Quick: standard settings, enough in most cases. Click Export (Go in older versions) and the .sql file downloads.
  • Custom: lets you choose which tables to export, whether to include structure, data or both, and compress the file with gzip or zip (very useful for large databases).

Quick and Custom export options

Keep the file on your computer and do not leave it in a public folder on the website: it contains your customers' data and the application's passwords.

Import a database

The file can be .sql, or compressed as .gz or .zip.

  1. Create the database in cPanel > Manage My Databases and assign it a user with all privileges.
  2. Open phpMyAdmin and click that database in the left-hand column.
  3. Open the Import tab.
  4. Select the file and click Go (or Import).

Before importing, open the .sql file in an editor and look for CREATE DATABASE or USE nombre_base; lines at the beginning. Delete them: phpMyAdmin will not let you create the database and, if the file points to another database, it will fail.

Import into an empty database. If the file contains DROP TABLE, it will replace any existing tables with the same name.

If the file is too large

The maximum size is shown on the Import screen, next to the button for choosing the file. Compress the .sql file as .zip or .gz: since it is text, it usually takes up to 90% less space and uploads faster.

If it still does not fit, or the import stops halfway, import it from the terminal over SSH. Upload the file to the account (outside public_html) and run:

mysql -u usuario_bd -p nombre_bd < copia.sql

If it is compressed as .gz:

gunzip < copia.sql.gz | mysql -u usuario_bd -p nombre_bd

It will ask for the database user's password. If an import fails halfway, empty the database (or create it again) before trying again, so you do not duplicate data. For specific errors, see phpMyAdmin import or export failure.

Designer

Among the advanced options is the Designer, little known but very useful: it shows the tables and their relationships as a visual diagram and lets you design the database structure. You will find it in the database's More > Designer tab.

phpMyAdmin's visual Designer with the tables and their relationships

To duplicate a whole database, follow how to clone a database.

You may also find useful

Something wrong or out of date? Tell us and we will review it.