How to Import Database Mysql Command Line Windows Xampp

How to Import Database Mysql Command Line Windows Xampp

If you are working with xampp in windows. And you want to create a table or update a table in Mysql database. So for this you have to execute query or import any sql file in mysql database.

Before you proceed, you must have XAMPP installed on your Windows machine. If you haven’t installed it yet, please read this :- How to Install XAMPP in Windows .

In this tutorial, you will learn how to import sql file or database in mysql using command line xampp windows.

How to Import a MySQL database using Command Line in XAMPP Windows

By using the following steps, you can import a mysql database using cmd or command prompt in XAMPP Windows:

  • Step 1: Open the Command Prompt
  • Step 2: Navigate to the MySQL bin directory
  • Step 3: Import the database or SQL File
  • Step 4: Enter the MySQL password
  • Step 5: Wait for the import to complete

Step 1: Open the Command Prompt

Firstly, start command prompt or cmd. So, to do this click on the Start menu, search for ‘cmd’, and click on the Command Prompt app.

Step 2: Navigate to the MySQL bin directory

Next, navigate to the MySQL bin directory. The location of the MySQL bin directory may vary depending on where you installed XAMPP on your system. By default, the path to the MySQL bin directory is ‘C:\xampp\mysql\bin’.

So, execute the following command on terminal to navigate to this directory:

cd C:\xampp\mysql\bin

Step 3: Import the database or SQL File

Execute the following command on command prompt or cmd to import database or sql file in mysql database:

mysql -u root -p your_database_name < your_sql_file.sql

In the above command, replace ‘your_database_name’ with the name of your database and ‘your_sql_file.sql’ with the name of your SQL file. Make sure that the SQL file is in the same directory as the command prompt.

Step 4: Enter the MySQL password

After executing the above command, you will be prompted to enter the MySQL password. Enter the password for the ‘root’ user and press Enter.

Step 5: Wait for the import to complete

After entering the password the import process will start. The time taken to complete the import process may vary depending on the size of the SQL file and the speed of your system.

Conclusion

Importing a MySQL database through the command line in Windows XAMPP is a straightforward process. By following the steps outlined in this tutorial, you can easily transfer data from one system to another. Remember to double-check the names of your database and SQL file, and make sure that the SQL file is in the same directory as the command prompt. With these precautions in place, you can successfully import your MySQL database through the command line.

Recommended Tutorials

AuthorAdmin

My name is Devendra Dode. I am a full-stack developer, entrepreneur, and owner of Tutsmake.com. I like writing tutorials and tips that can help other developers. I share tutorials of PHP, Python, Javascript, JQuery, Laravel, Livewire, Codeigniter, Node JS, Express JS, Vue JS, Angular JS, React Js, MySQL, MongoDB, REST APIs, Windows, Xampp, Linux, Ubuntu, Amazon AWS, Composer, SEO, WordPress, SSL and Bootstrap from a starting stage. As well as demo example.

Leave a Reply

Your email address will not be published. Required fields are marked *