user121196
user121196

Reputation: 31020

executing multiple mysql statements in a single session in bash

I have a large MySQL file that I need to execute statements from I also need to SET autocommit=0 before and COMMIT after executing this MySQL file.

I don’t want to create or modify files.

Is there a way to execute all 3 of them in one or multiple lines in a bash script?

Upvotes: 0

Views: 629

Answers (1)

Barmar
Barmar

Reputation: 780974

{ echo "SET autocommit = 0;"
  cat filename.sql
  echo "commit;" ; } | mysql

Upvotes: 1

Related Questions