In my folder, I have a lot of *.sql files... How via one command I can import them?
For example; is something like this possible?
mysql -u root -p db_development < *.sql
If not, how can I import every .sql file into MySQL?
This is the best one-line I know:
for SQL in *.sql; do DB=${SQL/\.sql/}; mysql $DB < $SQL; done
or with password:
for SQL in *.sql; do DB=${SQL/\.sql/}; mysql -u user --password=11111 $DB < $SQL; done"
Warning: the password is plain text so visible when using 'ps'.
cat *.sql | mysql -u root -p db_development
This will ask one time for the password.
If the statements belong to different databases, insert a USE databasename;
at the top of all .sql files.