On a CentOS server with LAMP I have a folder with 10-20 SQL dump files. Is there a way (single line query) by which I can import all of them?
I tried the following:
logged in putty, navigated to to file with all SQL dump say (folder
mysqlallfile
)mysqlallfile
contains:1.sql.gz
,2.sql.gz
and so onI created sh file say
bulkimport.sh
#!/bin/sh for filename in *.gz; do tempfile="${filename##*/}" database_name="${tempfile%%.*}" echo $database_name mysql -pPASS -u USER -e "CREATE DATABASE $database_name" gzcat $filename | mysql -pPASS -uUSER $database_name done
I ran below command in the terminal:
bash bulkimport.sh
it returned error:
bulkimport.sh: line 2: syntax error near unexpected token `$'\r'' 'ulkimport.sh: line 2: `for filename in *.gz;