How to Import Database Mysql Command Line Windows Xampp

1. Open the XAMPP Control Panel.

2. Start the Apache and MySQL modules.

3. Open the Command Prompt.

4. Navigate to the directory where the SQL file is located.

5. Type the following command to log in to MySQL as the root user:

mysql -u root -p

6. Enter the root user password when prompted.

7. Create the new database by typing the following command:

CREATE DATABASE database_name;

8. Select the database by typing the following command:

USE database_name;

9. Import the SQL file by typing the following command:

SOURCE path/to/file.sql;

10. Exit the MySQL prompt by typing the following command:

EXIT;
[ad_1]

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

[ad_2]

Jaspreet Singh Ghuman

Jaspreet Singh Ghuman

Jassweb.com/

Passionate Professional Blogger, Freelancer, WordPress Enthusiast, Digital Marketer, Web Developer, Server Operator, Networking Expert. Empowering online presence with diverse skills.

jassweb logo

Jassweb always keeps its services up-to-date with the latest trends in the market, providing its customers all over the world with high-end and easily extensible internet, intranet, and extranet products.

GSTIN is 03EGRPS4248R1ZD.

Contact
Jassweb, Rai Chak, Punjab, India. 143518
Item added to cart.
0 items - 0.00