{"id":884,"date":"2016-09-02T22:41:59","date_gmt":"2016-09-02T17:11:59","guid":{"rendered":"https:\/\/pheonixsolutions.com\/blog\/?p=884"},"modified":"2026-09-08T09:29:40","modified_gmt":"2026-09-08T03:59:40","slug":"restore-database-on-xampp-from-command-line","status":"publish","type":"post","link":"https:\/\/pheonixsolutions.com\/blog\/restore-database-on-xampp-from-command-line\/","title":{"rendered":"Restore the database on XAMPP from the command line"},"content":{"rendered":"\n<h2 class=\"wp-block-heading\">Introduction<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Restoring a large MySQL database through phpMyAdmin on XAMPP can be challenging because PHP configuration limits, such as <code>memory_limit<\/code>, <code>post_max_size<\/code>, and <code>max_execution_time<\/code> may prevent large SQL files from being uploaded or processed successfully.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">A simpler approach is to restore the database directly using the MySQL command line. This guide explains how to restore a MySQL database on a Windows machine running XAMPP.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><a href=\"https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2016\/09\/image.png\"><img fetchpriority=\"high\" decoding=\"async\" width=\"472\" height=\"302\" src=\"https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2016\/09\/image.png\" alt=\"\" class=\"wp-image-11492\" srcset=\"https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2016\/09\/image.png 472w, https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2016\/09\/image-300x192.png 300w\" sizes=\"(max-width: 472px) 100vw, 472px\" \/><\/a><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">Prerequisites<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Before starting, make sure you have:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>XAMPP installed on a Windows machine.<\/li>\n\n\n\n<li>MySQL service running through XAMPP.<\/li>\n\n\n\n<li>A MySQL database backup in <code>.sql<\/code> format.<\/li>\n\n\n\n<li>MySQL username and password, if authentication is configured.<\/li>\n\n\n\n<li>Access to the Windows Command Prompt.<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">Implementation<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">Step 1: Find the MySQL Installation Directory<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Open the <strong>XAMPP Control Panel<\/strong>.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Under the <strong>MySQL<\/strong> section, select:<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Config \u2192 my.ini<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Note down the MySQL installation directory.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Step 2: Open the Windows Command Prompt<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Open the Windows Run dialog:<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Press <code>Ctrl + R<\/code><\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Enter:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">cmd.exe<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Press <strong>Enter<\/strong> to open the Command Prompt.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Step 3: Move to the MySQL Binary Directory<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Navigate to the MySQL execution directory:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">cd &lt;mysql directory>\/mysql\/bin<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">For example, depending on your XAMPP installation, the directory may look similar to:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">cd C:\\xampp\\mysql\\bin<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Step 4: Copy the SQL Backup<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Copy the SQL database backup file into the MySQL <code>bin<\/code> directory.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">This is optional but makes the restore command easier to execute because you do not need to specify the complete path to the SQL file.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Step 5: Restore the Database<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Run the following command:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">mysql.exe -u &lt;username> &lt; database.sql<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Replace <code>&lt;username&gt;<\/code> with the MySQL username and <code>database.sql<\/code> with the name of your SQL backup file.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">For example:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">mysql.exe -u root &lt; database.sql<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">If the MySQL user requires a password, you can use:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">mysql.exe -u root -p &lt; database.sql<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">You will then be prompted to enter the MySQL password.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Step 6: Wait for the Restore to Complete<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">The SQL file will be processed directly by MySQL through the command line.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">For a large database, the restore may take some time. Wait until the command completes before closing the Command Prompt.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Conclusion<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Restoring a MySQL database through the command line is a practical alternative to phpMyAdmin, especially when working with large SQL backup files.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">By accessing the XAMPP MySQL binary directory and using the <code>mysql.exe<\/code> command, you can restore a database without depending on PHP upload and execution limits such as <code>memory_limit<\/code>, <code>post_max_size<\/code>, and <code>max_execution_time<\/code>.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">FAQs<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">1. Why use the command line instead of phpMyAdmin?<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">The command line avoids several PHP-related upload and execution limitations that can affect the restoration of large database backups through phpMyAdmin.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">2. Where is MySQL installed in XAMPP?<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">The MySQL installation is commonly located under the XAMPP installation directory, such as:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">C:\\xampp\\mysql<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">You can verify the actual installation directory from the XAMPP Control Panel.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">3. Can I restore a large SQL file using this method?<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Yes. Restoring through <code>mysql.exe<\/code> is particularly useful for large SQL backup files because it does not rely on phpMyAdmin&#8217;s web upload mechanism.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">4. What does the <code>&lt;<\/code> symbol do in the restore command?<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">The <code>&lt;<\/code> operator redirects the contents of the SQL backup file into the MySQL client, allowing MySQL to execute the SQL statements contained in the file.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">5. Can I restore the database with a password?<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Yes. Use the <code>-p<\/code> option:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">mysql.exe -u &lt;username> -p &lt; database.sql<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Related Articles<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>MySQL FIND_IN_SET with Multiple Search Strings<\/strong> \u2013 Learn how to use MySQL&#8217;s <code>FIND_IN_SET()<\/code> function when working with multiple search values.<br><a href=\"https:\/\/pheonixsolutions.com\/blog\/mysql-find_in_set-multiple-search-string\/?utm_source=chatgpt.com\" target=\"_blank\" rel=\"noreferrer noopener\">Read the article<\/a><\/li>\n\n\n\n<li><strong>Change WordPress Site URL from Backend Using MySQL\/MariaDB<\/strong> \u2013 Learn how to update WordPress site URL values directly from the MySQL\/MariaDB database.<br><a href=\"https:\/\/pheonixsolutions.com\/blog\/change-wordpress-site-url-backendmysql-mariadb\/?utm_source=chatgpt.com\" target=\"_blank\" rel=\"noreferrer noopener\">Read the article<\/a><\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">Talk to our experts<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Looking for the right technology solution for your business? Our team of experts can help you with development, cloud, DevOps, design, and a wide range of other technology needs. Get in touch with our team&nbsp;<a href=\"https:\/\/pheonixsolutions.com\/contact\" target=\"_blank\" rel=\"noreferrer noopener\">here<\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Introduction Restoring a large MySQL database through phpMyAdmin on XAMPP can be challenging because PHP configuration limits, such as memory_limit, [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"site-sidebar-layout":"default","site-content-layout":"","ast-site-content-layout":"default","site-content-style":"default","site-sidebar-style":"default","ast-global-header-display":"","ast-banner-title-visibility":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","ast-disable-related-posts":"","theme-transparent-header-meta":"","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","astra-migrate-meta-layouts":"default","ast-page-background-enabled":"default","ast-page-background-meta":{"desktop":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"ast-content-background-meta":{"desktop":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2},"jetpack_post_was_ever_published":false},"categories":[1019,1042],"tags":[],"class_list":["post-884","post","type-post","status-publish","format-standard","hentry","category-cloud-aws","category-databases","psol-cat-cloud-aws"],"jetpack_publicize_connections":[],"jetpack_shortlink":"https:\/\/wp.me\/phn2x7-eg","jetpack_sharing_enabled":true,"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/posts\/884","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/comments?post=884"}],"version-history":[{"count":2,"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/posts\/884\/revisions"}],"predecessor-version":[{"id":11499,"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/posts\/884\/revisions\/11499"}],"wp:attachment":[{"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/media?parent=884"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/categories?post=884"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/tags?post=884"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}