I have a sql file that I want to upload from the command line. To do this I first need to go into MySQL and create the database
mysql> create database myDB;
and then call the following from the command line:
mysql -u username -p myDB < myDB.sql
Is there a way to do this all in one line from the command line?
I tried adding the following lines (and various combinations) to the beginning of the myDB.sql file:
create database `myDB`;
use `myDB`;
and then running
mysql -u username -p < myDB.sql
but that did not work.
ERROR 1046 (3D000) at line 7: No database selected