Execute the sql file under the mysql command line

**********Execute the sql file under the mysql command line**********
C:\Windows\system32>cd E:\MySQL\mysql-5.7.16-winx64\bin //Switch the directory to the directory where the mysql bin file is located

C:\Windows\system32>mysql -uroot -p520462 -Dtest<E:\test.sql
//mysql -u account -p password -D database name < sql file absolute path

mysql: [Warning] Using a password on the command line interface can be insecure.
article dealer  price
0001    a       3.45
0001    b       3.99
0002    a       10.99
0003    b       1045.00
0003    c       1.69
0003    d       1.25
0004    d       19.95


mysql> source E:\test.sql //Execute source E:\test.sql under the mysql console
Database changed
ERROR:
No query specified
+---------+--------+---------+
| article | dealer | price   |
+---------+--------+---------+
|    0001 | a      |    3.45 |
|    0001 | b      |    3.99 |
|    0002 | a      |   10.99 |
|    0003 | b      | 1045.00 |
|    0003 | c      |    1.69 |
|    0003 | d      |    1.25 |
|    0004 | d      |   19.95 |
+---------+--------+---------+
7 rows in set (0.00 sec)

mysql> \. e:\test.sql             // \. e:\test.sql
Database changed
ERROR:
No query specified

+------+-------+------+
| year | month | day  |
+------+-------+------+
| 2000 |    01 |   01 |
| 2000 |    02 |   20 |
| 2000 |    01 |   30 |
| 2000 |    02 |   02 |
| 2000 |    02 |   23 |
| 2000 |    02 |   23 |
+------+-------+------+
6 rows in set (0.00 sec)

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325260611&siteId=291194637