How to Import Database in MySQL using Terminal

When it comes to handling large or very large SQL files, a seamless method to import them into your MySQL database is through the terminal. This approach is particularly efficient for substantial datasets and ensures a smooth process. Here’s a step-by-step guide:

Access Your Server via SSH:

Begin by logging into your server through SSH. This secure connection provides direct access to your server’s command-line interface.

Upload SQL File to /root via FTP:

Using FTP, upload your SQL file to the /root directory on your server. Ensure the file is correctly placed for easy retrieval.

Execute MySQL Import Command:

Once the SQL file is securely uploaded, initiate the import using the following command line:

For example:

Enter Your Password:

The terminal will prompt you to enter the password associated with the specified MySQL user. Provide the password and press Enter.

Monitor the Import Progress:

The terminal will commence the import process, displaying progress indicators as it works through the SQL file. Be patient, especially with larger files, as the process may take some time.

Completion Confirmation:

Once the import is complete, the terminal will return control. You’ll see a confirmation that the SQL file has been successfully imported into the specified database.

By following these steps, you can efficiently import large MySQL databases via the terminal, ensuring a streamlined process and effective management of substantial datasets.


Leave a Reply

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