Reputation: 301
The symbol < was used following query ,But i could not find why it is used and what its purpose
c:\>mysql -u root -p < create_database.sql
in create_database.sql consist of following
CREATE DATABASE sonar CHARACTER SET utf8 COLLATE utf8_general_ci;
CREATE USER 'sonar' IDENTIFIED BY 'sonar';
GRANT ALL ON sonar.* TO 'sonar'@'%' IDENTIFIED BY 'sonar';
GRANT ALL ON sonar.* TO 'sonar'@'localhost' IDENTIFIED BY 'sonar';
FLUSH PRIVILEGES;
Upvotes: 0
Views: 131
Reputation: 898
The <
character has nothing to do with mysql. It is part of the command line interface. It does stream redirection.
The mysql -u root -p < create_database.sql
line takes the contents of the create_database.sql
file and sets it as the input of the mysql -u root -p
command. The mysql
command reads the contents of the file as if it were typed in by the user.
Upvotes: 0
Reputation: 781068
That's Unix shell and Windows cmd.exe
syntax. It means that the file after <
should be used as standard input to the command. So it runs the mysql
command, and the contents of the create_database.sql
file will be read as input by mysql
, and it will perform those queries.
Upvotes: 2