Running "mysql" Commands from a Batch File in MySQL

Q

How To Run "mysql" Commands from a Batch File in MySQL?

✍: FYIcenter.com

A

If you have group of "mysql" commands that need to be executed repeatedly, you can put them into a file, and run them from the file in "mysql" batch mode. Here is a batch file, \temp\links.sql, contains following commands:

USE test;
INSERT INTO links VALUES (10, 'dba.fyicenter.com');
SELECT * FROM links;

To run this batch file, you need to follow this tutorial:

>cd \mysql\bin
>mysql -u root < \temp\links.sql
id      name
1       dba.fyicenter.com
10      dba.fyicenter.com

 

Command-Line End User Interface 'mysql'

⇒⇒MySQL Database Tutorials

2016-10-16, 230👍, 0💬