PressTigers

How to Import MySQL Database from Command Line

MySQL is an open source Relational Database Management System (RDBMS) that utilizes a Structured Query Language (SQL). It can be used with almost every technology whether it is open source or not. For any web application, developer have to create a local development server on local system and upload it to live server once development is completed.

Similarly for any customization/enhancement needed on a website, the developer downloads the whole site for backup. After that creates a local development environment on local system and uploads the new changes to the server. But what if the application’s MySQL database is large? As a consequence, problems arise while importing this large database on local system. In this article, you will find the guide by which you can import large MySQL database into your Apache server like wamp/xampp.

At first, export your database from phpmyadmin in .sql format. If you have already exported the database file in a compressed format then you have to extract it and then you will get .sql file.

Now let’s assume that you have a file name “pt_project_db.sql” and its size is almost 1GB. If you try to import it using phpymadmin, it will not import correctly. You have to import it from Command Line. First go to your Apache server installation folder, MySQL folder and then bin folder. Now open Command prompt on your system and write the following command:

Replace {drive} and {apache software} with your values. In our case, {drive} = C< and {apache software} = xampp so the final path will be as follows:

Now write a MySQL command that will import MySQL database into your database but before that create a separate database from phpmyadmin and save it with another name because you will need it later. After that, do not import anything in this database. Now, you need the following information:

  • Database file that you are going to import (e.g pt_project_db)
  • Database name in which the database file will be imported (e.g c:pt_project_db)
  • Database user name (e.g root)
  • Database user password (e.g. Pass)
    Note: password is empty in our case

Write the command listed below:

The final command will be:

Leave blank if you don’t have any password (as in our case) for Database user. If command prompt asks for a password, just press Enter key and wait until the database imports successfully (time depends on the size of your database file).

mysql_database_import

User Comments

Leave a Reply

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

    Get in Touch