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

1 Answer

+2 votes
by (71.8k points)
selected by
 
Best answer

- 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

 


...