简体   繁体   中英

executing a .sql file in command line

Doing

mysql -uroot -p -e source F:\code\mysql\mysql-data\myHfs\test.sql  

gives : ERROR 1049 (42000): Unknown database 'f:\\code\\mysql\\mysql-data\\myhfs\\test.sql'

But if i go inside the mysql command promt with just the mysql -uroot -p and then type in source F:\\code\\mysql\\mysql-data\\myHfs\\test.sql , i get the proper output.

the content of the above file being :

use gregs_list;
show tables;
select * from clown_info;

Edit : doing mysql -uroot -p < "F:\\code\\mysql\\mysql-data\\myHfs\\test.sql" -t seems to solve the problem.

http://dev.mysql.com/doc/refman/5.0/en/mysql-batch-commands.html

mysql -uroot -p < "F:\\code\\mysql\\mysql-data\\myHfs\\test.sql"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM