Importing large sql file to MySql via command line

后端 未结 5 899
猫巷女王i
猫巷女王i 2020-12-22 18:08

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

5条回答
  •  [愿得一人]
    2020-12-22 18:45

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

    mysql -u -p < file.sql

    Note: There shouldn't space between <-p> and

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

    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.

提交回复
热议问题