命令行导入mysql文件,通过命令行将大型SQL文件导入MySql

I'm trying to import an sql file of around 300MB to MySql via command line in Ubuntu. I used

source /var/www/myfile.sql;

Right now it's displaying a seemingly infinite rows of:

Query OK, 1 row affected (0.03 sec)

However it's been running a little while now. I've not imported a file this large before so I just want to know whether this is normal, if the process stalls or has some errors, will this show up in command line or will this process go on indefinitely?

Thanks

解决方案

You can import .sql file using the standard input like this:

mysql -u -p < file.sql

Note: There shouldn't space between and

Note for suggested edits: This answer was slightly changed by suggested edits to use inline password parameter. I can recommend it for scripts but you should be aware that when you write password directly in the parameter (-p) it may be cached by a shell history revealing your password to anyone who can read the history file. Whereas -p asks you to input password by standard input.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值