About 1,630,000 results
Open links in new tab
  1. mysql - How to execute a .sql script from bash - Stack Overflow

    Jan 6, 2018 · You simply need to start mysql and feed it with the content of db.sql: mysql -u user -p < db.sql or if you want to select the database right from the command line. mysql -u user -p database_name < db.sql

  2. Executing an SQL Script From the Command Line - Baeldung

    Apr 20, 2024 · In this article, we discussed how to execute a .sql script for MySQL from the Bash command line. First, we looked at the steps to connect to a MySQL server and also explored its various options. After that, we executed the .sql script using …

  3. command line - How to run SQL script in MySQL? - Stack Overflow

    Jan 20, 2012 · How do I keep mysql open after running the script? you can execute mysql statements that have been written in a text file using the following command: if your database has not been created yet, log into your mysql first using: then: that should do it! More info here: http://dev.mysql.com/doc/refman/5.0/en/mysql-batch-commands.html.

  4. MySQL: Run Query from Bash Script or Linux Command Line

    Dec 27, 2016 · How to connect to MySQL database and run SQL query from the Linux command-line (execute query from shell) or Bash script.

  5. How do you execute SQL from within a bash script?

    The tool can be used to run any SQL from the Linux bash or Windows command line. Example: java -jar sql-runner-0.2.0-with-dependencies.jar \ -j jdbc:oracle:thin:@//oracle-db:1521/ORCLPDB1.localdomain \ -U "SYS as SYSDBA" \ -P Oradoc_db1 \ "select 1 from dual"

  6. MySQL - How to run SQL file or script from the terminal

    Nov 2, 2021 · When you need to run a saved .sql file directly from the terminal, you can use the mysql command line client. You can run SQL scripts with or without opening a connection to the MySQL server. First, let’s see how to run SQL files while connected to a MySQL server. For example, suppose you have a file named main.sql with the following content:

  7. How to Run an SQL File in MySQL (or MariaDB) on Linux/Ubuntu

    Sep 13, 2022 · From the Shell/Command Line. You can also execute an SQL file without logging into MySQL from the Linux shell – this is especially useful if you wish to make your command part of a Bash/Shell script: mysql --host="mysql_server" --user="user_name" --database="database_name" --password="user_password" < "path/to/sql/file.sql"

  8. How to Run a SQL Script in MySQL from the Terminal

    Dec 27, 2023 · In this guide, you learned various methods for executing MySQL scripts from the Linux command line interface. Key takeaways include: Using SOURCE to run script files from within MySQL shell; Passing dynamic parameters to scripts ; Organizing reusable scripts effectively ; Running initialization scripts automatically on server start

  9. How to Run SQL Script: A Comprehensive Guide

    Jun 28, 2023 · Here are the steps to run an SQL script using the command line: Open a terminal or command prompt. Navigate to the folder where your SQL script is located. Connect to MySQL by entering: mysql -u [username] -p and pressing Enter. Type your password when prompted. Run your SQL script by entering: source [script_name.sql]. PostgreSQL

  10. command line - How to use SQL in terminal? - Ask Ubuntu

    Aug 9, 2017 · Here is the syntax to execute sql statement from terminal. I'm assuming that you are using MySQL. Syntax: Clearificance: Example: where root is the username, mydb is the name of the database. Similary you can execute any query you want. And of-course you can create a database using terminal itself.

  11. Some results have been removed
Refresh