أهم النقاط
- Export creates a .sql file you can keep as a backup or move to another server.
- Import into an empty database to avoid duplicate-table errors.
- Large databases import more reliably over SSH.
Export a database
- In cPanel, open Databases → phpMyAdmin.
- Select the database in the left sidebar.
- Click the Export tab.
- Choose Quick and format SQL for a complete export. Choose Custom if you want compression or to add
DROP TABLEstatements. - Click Export and save the
.sqlfile.
Import a database
- Create an empty database and user in MySQL Databases if you don’t have one, and give the user all privileges on it.
- In phpMyAdmin, select the empty database.
- Click Import, choose your
.sqlor.sql.gzfile and click Import. - A green success message lists how many queries ran.
Large databases: use SSH
# export
mysqldump -u dbuser -p dbname | gzip > dbname.sql.gz
# import
gunzip < dbname.sql.gz | mysql -u dbuser -p dbname
After moving a WordPress database
Update DB_NAME, DB_USER and DB_PASSWORD in wp-config.php. If the domain changed too, run a search-and-replace on the old URL — see the guide to moving WordPress to a new domain.
الأسئلة الشائعة
My import fails with a size error. What can I do?
Compress the file as .sql.gz (phpMyAdmin accepts it), raise the PHP upload limit, or import over SSH with the mysql command, which has no upload limit.
I get 'Table already exists'.
The target database isn't empty. Drop the existing tables first (after making sure you don't need them), or tick 'Add DROP TABLE' when exporting.