Run MySQL Statements in Batch Mode



We need to create a .sql file for running MySQL in batch mode. This file will contain the MySQL statements. Suppose I have hh.sql file in which I have written the statement select * from hh. With the help of the following command, we can run this file in batch mode −

Example

C:\Program Files\MySQL\bin>mysql -u root -p gaurav < hh.sql
Enter password: *****

Output

id
1
2

Here Gaurav is the database name that contains the table hh. Whenever you’ll run this command it will ask for the password and then give the output.

Updated on: 2020-06-22T05:00:18+05:30

391 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements