How Do I Run a Sql File in Linux?

How Do I Run a Sql File in Linux?
Contents

How do I run a .SQL file in Linux?

Create a sample database

  1. On your Linux machine, open a bash terminal session.
  2. Use sqlcmd to run a Transact-SQL CREATE DATABASE command. Bash Copy. /opt/mssql-tools/bin/sqlcmd -S localhost -U SA -Q ‘CREATE DATABASE SampleDB’
  3. Verify the database is created by listing the databases on your server. Bash Copy.

How do I run a SQL script in Linux terminal?

Open Terminal and type mysql -u to Open the MySQL command line. Type the path of your mysql bin directory and press Enter. Paste your SQL file inside the bin folder of mysql server. Create a database in MySQL.

Sarah Jenkins
Author

Sarah Jenkins

Sarah Jenkins is a veteran tech journalist with over 12 years of experience covering artificial intelligence, mobile innovations, and digital ethics. Her insights have appeared in leading technology publications worldwide.