+3 votes
in Databases by (11k points)
How can I run SQL queries in batch mode instead of running them one-by-one?

1 Answer

0 votes
by (11k points)
edited by

- Login to MySQL server typing the following command

mysql -u username -p  

It will prompt for password. Type your password and then it will take to mysql prompt (mysql>).

- Create a text file with your SQL queries (let's call it 1.sql)

- On mysql> prompt, type command source /path/to/1.sql

where /path/to - is the actual path of the file 1.sql on your system. For example, 

mysql> source /home/praveen/Documents/programming/mysql/1.sql

 

...