Facebook Twitter Instagram
    TecAdmin
    • Home
    • FeedBack
    • Submit Article
    • About Us
    Facebook Twitter Instagram
    TecAdmin
    You are at:Home»Databases»MySQL»How to Run SQL Text File on MySQL Command Prompt

    How to Run SQL Text File on MySQL Command Prompt

    By RahulJuly 26, 20171 Min Read

    Q. How do I run a SQL text file on MySQL prompt? How to source .sql file on MySQL command prompt? How do execute the .sql file in MySQL command prompt? How to Run SQL Text File on MySQL Command Prompt?

    Advertisement

    If you are on MySQL command prompt and need to execute all SQL queries contained in SQL file. You can simply do this by using source option to load any .sql file on your MySQL database. This executes all SQL queries available in a text file on selected database.

    For example, you have a database schema file schema.sql to load on the database. Now login to MySQL server and select database.

    $ mysql -u root -p
    
    mysql> USE mydb;
    

    After that, run the following command from the MySQL command prompt.

    mysql> source /home/user/Downloads/schema.sql
    

    The above command will run all the available SQL queries on selected database (mydb in my case).

    MySQL source
    Share. Facebook Twitter Pinterest LinkedIn Tumblr Email WhatsApp

    Related Posts

    A Comprehensive Guide to Optimizing MySQL Table

    Create a Basic CRUD API in NodeJS, ExpressJS and MySQL

    How to Optimize MySQL Parameters for a 32 GB RAM System

    View 1 Comment

    1 Comment

    1. Rafael on May 22, 2022 4:31 pm

      Thank you!

      Reply

    Leave A Reply Cancel Reply

    Advertisement
    Recent Posts
    • Setting and Getting the Default Timezone in Python
    • What is Media Access Control (MAC) Address?
    • What is Cross-Site Scripting (XSS)?
    • What is Content Security Policy (CSP)?
    • A User’s Guide to Understanding Redirection Operators in Bash
    Facebook Twitter Instagram Pinterest
    © 2023 Tecadmin.net. All Rights Reserved | Terms  | Privacy Policy

    Type above and press Enter to search. Press Esc to cancel.