Import Multiple .sql dump files into mysql database from shell

前端 未结 5 1818
半阙折子戏
半阙折子戏 2020-12-12 14:06

I have a directory with a bunch of .sql files that mysql dumps of each database on my server.

e.g.

database1-2011-01-15.sql
database2-2         


        
5条回答
  •  鱼传尺愫
    2020-12-12 14:25

    cat *.sql | mysql? Do you need them in any specific order?

    If you have too many to handle this way, then try something like:

    find . -name '*.sql' | awk '{ print "source",$0 }' | mysql --batch
    

    This also gets around some problems with passing script input through a pipeline though you shouldn't have any problems with pipeline processing under Linux. The nice thing about this approach is that the mysql utility reads in each file instead of having it read from stdin.

提交回复
热议问题