How can we run MySQL statements in batch mode?

MySQLMySQLi Database

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.

raja
Published on 21-Feb-2018 06:58:27
Advertisements