Restore Database on Xampp from command line
Restoring a large MySQL database through phpMyAdmin can often fail due to PHP limitations such as memory_limit, post_max_size, and max_execution_time. Using the MySQL command line is a faster and more reliable method, especially for large database backups. This guide explains how to restore a MySQL database in XAMPP using the Windows Command Prompt.
Introduction
XAMPP includes the MySQL command-line client, which can be used to restore SQL database backups directly from the command prompt. This method avoids the upload size and execution time limitations commonly encountered when using phpMyAdmin.
Prerequisites
- XAMPP installed on the Windows system
- MySQL service running in XAMPP
- Command Prompt access
- Existing MySQL database to restore into
- SQL database backup file (
.sql) - MySQL user account with permission to restore the database
Implementation
Step 1
Open the XAMPP Control Panel.
Under the MySQL section, click Config and note the MySQL installation directory.
Step 2
Open the Run dialog by pressing Ctrl + R.
Type the following command and press Enter.
cmd.exe
Step 3
Navigate to the MySQL bin directory.
cd <mysql_directory>\mysql\bin
Replace <mysql_directory> with your MySQL installation path.
Step 4
Copy the SQL database backup file (.sql) into the MySQL bin directory.
Step 5
Run the following command to restore the database.
mysql.exe -u <username> < database.sql
Replace <username> with your MySQL username and database.sql with the SQL backup file name.
Step 6
Wait for the restore process to complete successfully. The time required depends on the size of the database backup.
Conclusion
Restoring a MySQL database using the command line is a simple and efficient way to import large database backups in XAMPP. This approach avoids the upload and execution limitations of phpMyAdmin, making the restoration process faster and more reliable.

