问题

软件 >> MySQL
Questions in category: MySQL (MySQL).

mysql.exe 使用 -e 选项执行命令

Posted by haifeng on 2020-11-10 11:36:35 last update 2020-11-10 11:36:35 | Answers (0) | 收藏


当使用 msyql.exe 及选项 -e 执行命令时, 必须要加双引号. (单引号以及`` 都不行)

C:\Users\Administrator>mysql -uroot -p -e show databases
Enter password: ******
ERROR 1049 (42000): Unknown database 'databases'

 

C:\Users\Administrator>mysql -uroot -p -e "show databases"
Enter password: ******
+-------------------------+
| Database                |
+-------------------------+
| information_schema      |
| math                    |
| mysql                   |
| performance_schema      |
| test                    |
| test_bar                |
| test_electronicproducts |
| test_shipsinww2         |
+-------------------------+