Import .sql file to Mysql RailwayDB using command line.

Updated: Feb 17, 2025

Import .sql file to Mysql RailwayDB using command line.

To import an .sql file into MySQL using the command line, follow these steps:

  1. First, make sure you have MySQL installed on your system and that you have access to the MySQL command line interface. You can download MySQL from the official website (https://dev.mysql.com/downloads/mysql/) and follow the installation instructions.

  2. Open a terminal or command prompt window and type the following command to log in to the MySQL server:

    mysql -u [username] -p [database_name]
    

    Replace [username] with your MySQL username and [database_name] with the name of the database where you want to import the SQL file. You will be prompted to enter your password.

  3. Once you are logged in to the MySQL command line interface, use the SOURCE command to import the SQL file. Type the following command, replacing [file_path] with the path to the location of your .sql file on your system:

    SOURCE [file_path]/[file_name].sql;
    

    Replace [file_path] with the absolute or relative path to the directory containing the .sql file, and [file_name] with the name of the .sql file without the .sql extension.

  4. If the SQL file contains any errors, you will see an error message in the command line output. If the import is successful, you will not see any output.

  5. To exit the MySQL command line interface, type the following command:

    exit;
    

That's it! Your .sql file has been imported into MySQL using the command line. Let me know if you have any questions or if there's anything else I can help you with.