Requirements Description :
In the use of MySQL database, sometimes you need to execute a SQL script file directly on the Shell's command line,
For example, to initialize a database, create a specific stored procedure, create a table, and so on, perform a basic test.
In general, MySQL is logged in interactively, executing SQL statements. All you have to do is put SQL in a file and let MySQL
Client program to execute.
Operation Process :
1. Create a SQL script text file that contains the SQL statement you want to execute
Use test01 Select Count (* from ts051;
Note: The file name of the SQL script, Secount.sql,use specifies the name of the database.
2. In the shell command line, invoke the MySQL command to execute the SQL script
< secount.sql Enter Password: #输入root用户的密码. count (*)557107
Note: On the command line, to specify the user to connect to the database, you do not need to specify the database you want to use with the-D parameter in the script if you indicate the database to be used by using the.
Summary :
In the command line, execute the script by invoking the MySQL command, and then using the < less than sign to input the contents of the SQL script.
Document creation time: March 20, 2018 11:28:17
How do I execute a SQL script file on the command line in MySQL?