How Can I Execute an SQL File Correctly Within MySQL in Windows 10 Command Prompt?












0















I have been trying almost thirty minutes trying to figure out how to execute an sql file from a Win 10 command prompt and I still can't figure out how to do it.



I am in the mysql> directory and I can't figure out what the 'source' is before the path to the file. What is the 'source' that I need to type in before the path to the MySql file?



Here is my file path to the bookorama.sql file that I am trying to execute:
C:wamp64binmysqlmysql5.7.23bin



The bookorama.sql is within the file path at the last 'bin' folder.



Here's what I have tried to find so far, but I keep on trying a lot of the suggestions for the answers in these posts, but I still can't get it right.



Can't run MySQL from command prompt



Executing a SQL file



How to import an SQL file using the command line in MySQL?



execute .sql file using command line



https://tecadmin.net/run-sql-text-file-on-mysql-command-prompt/



Here's a copy of the command prompt tries to execute the sql file:



C:wamp64binmysqlmysql5.7.23bin>mysql -hlocalhost -uroot -p
Enter password: *********
Welcome to the MySQL monitor. Commands end with ; or g.
Your MySQL connection id is 22
Server version: 5.7.23 MySQL Community Server (GPL)

Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or 'h' for help. Type 'c' to clear the current input

mysql> use books
Database changed
mysql> -u bookorama -d books < bookoroma.sql
-> ;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual
that corresponds to your MySQL server version for the right syntax to use
near '-u bookorama -d books < bookoroma.sql' at line 1
mysql> mysql
-> ;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual
that corresponds to your MySQL server version for the right syntax to use
near 'mysql' at line 1
mysql> mysql -h localhost - u bookorama -p < bookorama.sql
-> ;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual
that corresponds to your MySQL server version for the right syntax to use
near 'mysql -h localhost - u bookorama -p < bookorama.sql' at line 1
mysql> cd..
-> ;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual
that corresponds to your MySQL server version for the right syntax to use
near 'cd..' at line 1
mysql> mysql -h localhost -u bookorama -D books -p < bookorama.sql
->
-> CREATE TABLE Customers
-> ;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual
that corresponds to your MySQL server version for the right syntax to use
near 'mysql -h localhost -u bookorama -D books -p < bookorama.sql

CREATE TABLE Custom' at line 1
mysql> -u bookorama -D books -P < bookorama.sql
-> ;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual
that corresponds to your MySQL server version for the right syntax to use
near '-u bookorama -D books -P < bookorama.sql' at line 1mysql> -u root
-> -p Oscar545* -D bookorama < bookorama.sql
-> ;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual
that corresponds to your MySQL server version for the right syntax to use
near '-u root
-p Oscar545* -D bookorama < bookorama.sql' at line 1
mysql> mysql -h localhose u-root -D bookorama <
C:wamp64binmysqlmysql5.7.23bin.bookorama.sql
Show warnings disabled.
ERROR:
Unknown command 'b'.
ERROR:
Unknown command 'm'.
ERROR:
Unknown command 'm'.
ERROR:
Unknown command 'b'.
-> ;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual
that corresponds to your MySQL server version for the right syntax to use
near 'mysql -h localhose u-root -D bookorama <
C:amp64binmysqlmysql5.7.23bin.booko' at line 1
mysql> mysql -h localhose u-root -D bookorama < bookorama.sql
-> ;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual
that corresponds to your MySQL server version for the right syntax to use
near 'mysql -h localhose u-root -D bookorama < bookorama.sql' at line 1
mysql> mysql -u root -p books < bookorama.sql
-> ;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual
that corresponds to your MySQL server version for the right syntax to use
near 'mysql -u root -p books < bookorama.sql' at line 1
mysql> use books
Database changed
mysql> mysql -u root -p books < bookorama.sql
-> ;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual
that corresponds to your MySQL server version for the right syntax to use
near 'mysql -u root -p books < bookorama.sql' at line 1
mysql> C:wamp64binmysqlmysql5.7.23bin bookorama.sql
Show warnings disabled.ERROR:
Unknown command 'b'.
ERROR:
Unknown command 'm'.
ERROR:
Unknown command 'm'.
ERROR:
Unknown command 'b'.
-> ;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual
that corresponds to your MySQL server version for the right syntax to use
near 'C:amp64binmysqlmysql5.7.23bin bookorama.sql' at line 1
mysql> source C:wamp64binmysqlmysql5.7.23bin;
Show warnings disabled.
ERROR:
Unknown command 'b'.
ERROR:
Unknown command 'm'.
ERROR:
Unknown command 'm'.
ERROR:
Unknown command 'b'.
ERROR:
Failed to open file 'C:amp64binmysqlmysql5.7.23bin', error: 2
mysql> C:wamp64binmysqlmysql5.7.23binbookorama.sql
Show warnings disabled.
ERROR:
Unknown command 'b'.
ERROR:
Unknown command 'm'.
ERROR:
Unknown command 'm'.
ERROR:
Unknown command 'b'.
ERROR:
Unknown command 'b'.
-> ;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual
that corresponds to your MySQL server version for the right syntax to use
near 'C:amp64binmysqlmysql5.7.23binbookorama.sql' at line 1
mysql> mysql -h localhost -u root
-> ;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual
that corresponds to your MySQL server version for the right syntax to use
near 'mysql -h localhost -u root' at line 1
mysql> -h localhost -root -pOscar545* books < bookorama.sql
-> ;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual
that corresponds to your MySQL server version for the right syntax to use
near '-h localhost -root -pOscar545* books < bookorama.sql' at line 1
mysql> mysql -u root -p books < bookorama.sql
-> ;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual
that corresponds to your MySQL server version for the right syntax to use
near 'mysql -u root -p books < bookorama.sql' at line 1
mysql>









share|improve this question



























    0















    I have been trying almost thirty minutes trying to figure out how to execute an sql file from a Win 10 command prompt and I still can't figure out how to do it.



    I am in the mysql> directory and I can't figure out what the 'source' is before the path to the file. What is the 'source' that I need to type in before the path to the MySql file?



    Here is my file path to the bookorama.sql file that I am trying to execute:
    C:wamp64binmysqlmysql5.7.23bin



    The bookorama.sql is within the file path at the last 'bin' folder.



    Here's what I have tried to find so far, but I keep on trying a lot of the suggestions for the answers in these posts, but I still can't get it right.



    Can't run MySQL from command prompt



    Executing a SQL file



    How to import an SQL file using the command line in MySQL?



    execute .sql file using command line



    https://tecadmin.net/run-sql-text-file-on-mysql-command-prompt/



    Here's a copy of the command prompt tries to execute the sql file:



    C:wamp64binmysqlmysql5.7.23bin>mysql -hlocalhost -uroot -p
    Enter password: *********
    Welcome to the MySQL monitor. Commands end with ; or g.
    Your MySQL connection id is 22
    Server version: 5.7.23 MySQL Community Server (GPL)

    Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.

    Oracle is a registered trademark of Oracle Corporation and/or its
    affiliates. Other names may be trademarks of their respective
    owners.

    Type 'help;' or 'h' for help. Type 'c' to clear the current input

    mysql> use books
    Database changed
    mysql> -u bookorama -d books < bookoroma.sql
    -> ;
    ERROR 1064 (42000): You have an error in your SQL syntax; check the manual
    that corresponds to your MySQL server version for the right syntax to use
    near '-u bookorama -d books < bookoroma.sql' at line 1
    mysql> mysql
    -> ;
    ERROR 1064 (42000): You have an error in your SQL syntax; check the manual
    that corresponds to your MySQL server version for the right syntax to use
    near 'mysql' at line 1
    mysql> mysql -h localhost - u bookorama -p < bookorama.sql
    -> ;
    ERROR 1064 (42000): You have an error in your SQL syntax; check the manual
    that corresponds to your MySQL server version for the right syntax to use
    near 'mysql -h localhost - u bookorama -p < bookorama.sql' at line 1
    mysql> cd..
    -> ;
    ERROR 1064 (42000): You have an error in your SQL syntax; check the manual
    that corresponds to your MySQL server version for the right syntax to use
    near 'cd..' at line 1
    mysql> mysql -h localhost -u bookorama -D books -p < bookorama.sql
    ->
    -> CREATE TABLE Customers
    -> ;
    ERROR 1064 (42000): You have an error in your SQL syntax; check the manual
    that corresponds to your MySQL server version for the right syntax to use
    near 'mysql -h localhost -u bookorama -D books -p < bookorama.sql

    CREATE TABLE Custom' at line 1
    mysql> -u bookorama -D books -P < bookorama.sql
    -> ;
    ERROR 1064 (42000): You have an error in your SQL syntax; check the manual
    that corresponds to your MySQL server version for the right syntax to use
    near '-u bookorama -D books -P < bookorama.sql' at line 1mysql> -u root
    -> -p Oscar545* -D bookorama < bookorama.sql
    -> ;
    ERROR 1064 (42000): You have an error in your SQL syntax; check the manual
    that corresponds to your MySQL server version for the right syntax to use
    near '-u root
    -p Oscar545* -D bookorama < bookorama.sql' at line 1
    mysql> mysql -h localhose u-root -D bookorama <
    C:wamp64binmysqlmysql5.7.23bin.bookorama.sql
    Show warnings disabled.
    ERROR:
    Unknown command 'b'.
    ERROR:
    Unknown command 'm'.
    ERROR:
    Unknown command 'm'.
    ERROR:
    Unknown command 'b'.
    -> ;
    ERROR 1064 (42000): You have an error in your SQL syntax; check the manual
    that corresponds to your MySQL server version for the right syntax to use
    near 'mysql -h localhose u-root -D bookorama <
    C:amp64binmysqlmysql5.7.23bin.booko' at line 1
    mysql> mysql -h localhose u-root -D bookorama < bookorama.sql
    -> ;
    ERROR 1064 (42000): You have an error in your SQL syntax; check the manual
    that corresponds to your MySQL server version for the right syntax to use
    near 'mysql -h localhose u-root -D bookorama < bookorama.sql' at line 1
    mysql> mysql -u root -p books < bookorama.sql
    -> ;
    ERROR 1064 (42000): You have an error in your SQL syntax; check the manual
    that corresponds to your MySQL server version for the right syntax to use
    near 'mysql -u root -p books < bookorama.sql' at line 1
    mysql> use books
    Database changed
    mysql> mysql -u root -p books < bookorama.sql
    -> ;
    ERROR 1064 (42000): You have an error in your SQL syntax; check the manual
    that corresponds to your MySQL server version for the right syntax to use
    near 'mysql -u root -p books < bookorama.sql' at line 1
    mysql> C:wamp64binmysqlmysql5.7.23bin bookorama.sql
    Show warnings disabled.ERROR:
    Unknown command 'b'.
    ERROR:
    Unknown command 'm'.
    ERROR:
    Unknown command 'm'.
    ERROR:
    Unknown command 'b'.
    -> ;
    ERROR 1064 (42000): You have an error in your SQL syntax; check the manual
    that corresponds to your MySQL server version for the right syntax to use
    near 'C:amp64binmysqlmysql5.7.23bin bookorama.sql' at line 1
    mysql> source C:wamp64binmysqlmysql5.7.23bin;
    Show warnings disabled.
    ERROR:
    Unknown command 'b'.
    ERROR:
    Unknown command 'm'.
    ERROR:
    Unknown command 'm'.
    ERROR:
    Unknown command 'b'.
    ERROR:
    Failed to open file 'C:amp64binmysqlmysql5.7.23bin', error: 2
    mysql> C:wamp64binmysqlmysql5.7.23binbookorama.sql
    Show warnings disabled.
    ERROR:
    Unknown command 'b'.
    ERROR:
    Unknown command 'm'.
    ERROR:
    Unknown command 'm'.
    ERROR:
    Unknown command 'b'.
    ERROR:
    Unknown command 'b'.
    -> ;
    ERROR 1064 (42000): You have an error in your SQL syntax; check the manual
    that corresponds to your MySQL server version for the right syntax to use
    near 'C:amp64binmysqlmysql5.7.23binbookorama.sql' at line 1
    mysql> mysql -h localhost -u root
    -> ;
    ERROR 1064 (42000): You have an error in your SQL syntax; check the manual
    that corresponds to your MySQL server version for the right syntax to use
    near 'mysql -h localhost -u root' at line 1
    mysql> -h localhost -root -pOscar545* books < bookorama.sql
    -> ;
    ERROR 1064 (42000): You have an error in your SQL syntax; check the manual
    that corresponds to your MySQL server version for the right syntax to use
    near '-h localhost -root -pOscar545* books < bookorama.sql' at line 1
    mysql> mysql -u root -p books < bookorama.sql
    -> ;
    ERROR 1064 (42000): You have an error in your SQL syntax; check the manual
    that corresponds to your MySQL server version for the right syntax to use
    near 'mysql -u root -p books < bookorama.sql' at line 1
    mysql>









    share|improve this question

























      0












      0








      0








      I have been trying almost thirty minutes trying to figure out how to execute an sql file from a Win 10 command prompt and I still can't figure out how to do it.



      I am in the mysql> directory and I can't figure out what the 'source' is before the path to the file. What is the 'source' that I need to type in before the path to the MySql file?



      Here is my file path to the bookorama.sql file that I am trying to execute:
      C:wamp64binmysqlmysql5.7.23bin



      The bookorama.sql is within the file path at the last 'bin' folder.



      Here's what I have tried to find so far, but I keep on trying a lot of the suggestions for the answers in these posts, but I still can't get it right.



      Can't run MySQL from command prompt



      Executing a SQL file



      How to import an SQL file using the command line in MySQL?



      execute .sql file using command line



      https://tecadmin.net/run-sql-text-file-on-mysql-command-prompt/



      Here's a copy of the command prompt tries to execute the sql file:



      C:wamp64binmysqlmysql5.7.23bin>mysql -hlocalhost -uroot -p
      Enter password: *********
      Welcome to the MySQL monitor. Commands end with ; or g.
      Your MySQL connection id is 22
      Server version: 5.7.23 MySQL Community Server (GPL)

      Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.

      Oracle is a registered trademark of Oracle Corporation and/or its
      affiliates. Other names may be trademarks of their respective
      owners.

      Type 'help;' or 'h' for help. Type 'c' to clear the current input

      mysql> use books
      Database changed
      mysql> -u bookorama -d books < bookoroma.sql
      -> ;
      ERROR 1064 (42000): You have an error in your SQL syntax; check the manual
      that corresponds to your MySQL server version for the right syntax to use
      near '-u bookorama -d books < bookoroma.sql' at line 1
      mysql> mysql
      -> ;
      ERROR 1064 (42000): You have an error in your SQL syntax; check the manual
      that corresponds to your MySQL server version for the right syntax to use
      near 'mysql' at line 1
      mysql> mysql -h localhost - u bookorama -p < bookorama.sql
      -> ;
      ERROR 1064 (42000): You have an error in your SQL syntax; check the manual
      that corresponds to your MySQL server version for the right syntax to use
      near 'mysql -h localhost - u bookorama -p < bookorama.sql' at line 1
      mysql> cd..
      -> ;
      ERROR 1064 (42000): You have an error in your SQL syntax; check the manual
      that corresponds to your MySQL server version for the right syntax to use
      near 'cd..' at line 1
      mysql> mysql -h localhost -u bookorama -D books -p < bookorama.sql
      ->
      -> CREATE TABLE Customers
      -> ;
      ERROR 1064 (42000): You have an error in your SQL syntax; check the manual
      that corresponds to your MySQL server version for the right syntax to use
      near 'mysql -h localhost -u bookorama -D books -p < bookorama.sql

      CREATE TABLE Custom' at line 1
      mysql> -u bookorama -D books -P < bookorama.sql
      -> ;
      ERROR 1064 (42000): You have an error in your SQL syntax; check the manual
      that corresponds to your MySQL server version for the right syntax to use
      near '-u bookorama -D books -P < bookorama.sql' at line 1mysql> -u root
      -> -p Oscar545* -D bookorama < bookorama.sql
      -> ;
      ERROR 1064 (42000): You have an error in your SQL syntax; check the manual
      that corresponds to your MySQL server version for the right syntax to use
      near '-u root
      -p Oscar545* -D bookorama < bookorama.sql' at line 1
      mysql> mysql -h localhose u-root -D bookorama <
      C:wamp64binmysqlmysql5.7.23bin.bookorama.sql
      Show warnings disabled.
      ERROR:
      Unknown command 'b'.
      ERROR:
      Unknown command 'm'.
      ERROR:
      Unknown command 'm'.
      ERROR:
      Unknown command 'b'.
      -> ;
      ERROR 1064 (42000): You have an error in your SQL syntax; check the manual
      that corresponds to your MySQL server version for the right syntax to use
      near 'mysql -h localhose u-root -D bookorama <
      C:amp64binmysqlmysql5.7.23bin.booko' at line 1
      mysql> mysql -h localhose u-root -D bookorama < bookorama.sql
      -> ;
      ERROR 1064 (42000): You have an error in your SQL syntax; check the manual
      that corresponds to your MySQL server version for the right syntax to use
      near 'mysql -h localhose u-root -D bookorama < bookorama.sql' at line 1
      mysql> mysql -u root -p books < bookorama.sql
      -> ;
      ERROR 1064 (42000): You have an error in your SQL syntax; check the manual
      that corresponds to your MySQL server version for the right syntax to use
      near 'mysql -u root -p books < bookorama.sql' at line 1
      mysql> use books
      Database changed
      mysql> mysql -u root -p books < bookorama.sql
      -> ;
      ERROR 1064 (42000): You have an error in your SQL syntax; check the manual
      that corresponds to your MySQL server version for the right syntax to use
      near 'mysql -u root -p books < bookorama.sql' at line 1
      mysql> C:wamp64binmysqlmysql5.7.23bin bookorama.sql
      Show warnings disabled.ERROR:
      Unknown command 'b'.
      ERROR:
      Unknown command 'm'.
      ERROR:
      Unknown command 'm'.
      ERROR:
      Unknown command 'b'.
      -> ;
      ERROR 1064 (42000): You have an error in your SQL syntax; check the manual
      that corresponds to your MySQL server version for the right syntax to use
      near 'C:amp64binmysqlmysql5.7.23bin bookorama.sql' at line 1
      mysql> source C:wamp64binmysqlmysql5.7.23bin;
      Show warnings disabled.
      ERROR:
      Unknown command 'b'.
      ERROR:
      Unknown command 'm'.
      ERROR:
      Unknown command 'm'.
      ERROR:
      Unknown command 'b'.
      ERROR:
      Failed to open file 'C:amp64binmysqlmysql5.7.23bin', error: 2
      mysql> C:wamp64binmysqlmysql5.7.23binbookorama.sql
      Show warnings disabled.
      ERROR:
      Unknown command 'b'.
      ERROR:
      Unknown command 'm'.
      ERROR:
      Unknown command 'm'.
      ERROR:
      Unknown command 'b'.
      ERROR:
      Unknown command 'b'.
      -> ;
      ERROR 1064 (42000): You have an error in your SQL syntax; check the manual
      that corresponds to your MySQL server version for the right syntax to use
      near 'C:amp64binmysqlmysql5.7.23binbookorama.sql' at line 1
      mysql> mysql -h localhost -u root
      -> ;
      ERROR 1064 (42000): You have an error in your SQL syntax; check the manual
      that corresponds to your MySQL server version for the right syntax to use
      near 'mysql -h localhost -u root' at line 1
      mysql> -h localhost -root -pOscar545* books < bookorama.sql
      -> ;
      ERROR 1064 (42000): You have an error in your SQL syntax; check the manual
      that corresponds to your MySQL server version for the right syntax to use
      near '-h localhost -root -pOscar545* books < bookorama.sql' at line 1
      mysql> mysql -u root -p books < bookorama.sql
      -> ;
      ERROR 1064 (42000): You have an error in your SQL syntax; check the manual
      that corresponds to your MySQL server version for the right syntax to use
      near 'mysql -u root -p books < bookorama.sql' at line 1
      mysql>









      share|improve this question














      I have been trying almost thirty minutes trying to figure out how to execute an sql file from a Win 10 command prompt and I still can't figure out how to do it.



      I am in the mysql> directory and I can't figure out what the 'source' is before the path to the file. What is the 'source' that I need to type in before the path to the MySql file?



      Here is my file path to the bookorama.sql file that I am trying to execute:
      C:wamp64binmysqlmysql5.7.23bin



      The bookorama.sql is within the file path at the last 'bin' folder.



      Here's what I have tried to find so far, but I keep on trying a lot of the suggestions for the answers in these posts, but I still can't get it right.



      Can't run MySQL from command prompt



      Executing a SQL file



      How to import an SQL file using the command line in MySQL?



      execute .sql file using command line



      https://tecadmin.net/run-sql-text-file-on-mysql-command-prompt/



      Here's a copy of the command prompt tries to execute the sql file:



      C:wamp64binmysqlmysql5.7.23bin>mysql -hlocalhost -uroot -p
      Enter password: *********
      Welcome to the MySQL monitor. Commands end with ; or g.
      Your MySQL connection id is 22
      Server version: 5.7.23 MySQL Community Server (GPL)

      Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.

      Oracle is a registered trademark of Oracle Corporation and/or its
      affiliates. Other names may be trademarks of their respective
      owners.

      Type 'help;' or 'h' for help. Type 'c' to clear the current input

      mysql> use books
      Database changed
      mysql> -u bookorama -d books < bookoroma.sql
      -> ;
      ERROR 1064 (42000): You have an error in your SQL syntax; check the manual
      that corresponds to your MySQL server version for the right syntax to use
      near '-u bookorama -d books < bookoroma.sql' at line 1
      mysql> mysql
      -> ;
      ERROR 1064 (42000): You have an error in your SQL syntax; check the manual
      that corresponds to your MySQL server version for the right syntax to use
      near 'mysql' at line 1
      mysql> mysql -h localhost - u bookorama -p < bookorama.sql
      -> ;
      ERROR 1064 (42000): You have an error in your SQL syntax; check the manual
      that corresponds to your MySQL server version for the right syntax to use
      near 'mysql -h localhost - u bookorama -p < bookorama.sql' at line 1
      mysql> cd..
      -> ;
      ERROR 1064 (42000): You have an error in your SQL syntax; check the manual
      that corresponds to your MySQL server version for the right syntax to use
      near 'cd..' at line 1
      mysql> mysql -h localhost -u bookorama -D books -p < bookorama.sql
      ->
      -> CREATE TABLE Customers
      -> ;
      ERROR 1064 (42000): You have an error in your SQL syntax; check the manual
      that corresponds to your MySQL server version for the right syntax to use
      near 'mysql -h localhost -u bookorama -D books -p < bookorama.sql

      CREATE TABLE Custom' at line 1
      mysql> -u bookorama -D books -P < bookorama.sql
      -> ;
      ERROR 1064 (42000): You have an error in your SQL syntax; check the manual
      that corresponds to your MySQL server version for the right syntax to use
      near '-u bookorama -D books -P < bookorama.sql' at line 1mysql> -u root
      -> -p Oscar545* -D bookorama < bookorama.sql
      -> ;
      ERROR 1064 (42000): You have an error in your SQL syntax; check the manual
      that corresponds to your MySQL server version for the right syntax to use
      near '-u root
      -p Oscar545* -D bookorama < bookorama.sql' at line 1
      mysql> mysql -h localhose u-root -D bookorama <
      C:wamp64binmysqlmysql5.7.23bin.bookorama.sql
      Show warnings disabled.
      ERROR:
      Unknown command 'b'.
      ERROR:
      Unknown command 'm'.
      ERROR:
      Unknown command 'm'.
      ERROR:
      Unknown command 'b'.
      -> ;
      ERROR 1064 (42000): You have an error in your SQL syntax; check the manual
      that corresponds to your MySQL server version for the right syntax to use
      near 'mysql -h localhose u-root -D bookorama <
      C:amp64binmysqlmysql5.7.23bin.booko' at line 1
      mysql> mysql -h localhose u-root -D bookorama < bookorama.sql
      -> ;
      ERROR 1064 (42000): You have an error in your SQL syntax; check the manual
      that corresponds to your MySQL server version for the right syntax to use
      near 'mysql -h localhose u-root -D bookorama < bookorama.sql' at line 1
      mysql> mysql -u root -p books < bookorama.sql
      -> ;
      ERROR 1064 (42000): You have an error in your SQL syntax; check the manual
      that corresponds to your MySQL server version for the right syntax to use
      near 'mysql -u root -p books < bookorama.sql' at line 1
      mysql> use books
      Database changed
      mysql> mysql -u root -p books < bookorama.sql
      -> ;
      ERROR 1064 (42000): You have an error in your SQL syntax; check the manual
      that corresponds to your MySQL server version for the right syntax to use
      near 'mysql -u root -p books < bookorama.sql' at line 1
      mysql> C:wamp64binmysqlmysql5.7.23bin bookorama.sql
      Show warnings disabled.ERROR:
      Unknown command 'b'.
      ERROR:
      Unknown command 'm'.
      ERROR:
      Unknown command 'm'.
      ERROR:
      Unknown command 'b'.
      -> ;
      ERROR 1064 (42000): You have an error in your SQL syntax; check the manual
      that corresponds to your MySQL server version for the right syntax to use
      near 'C:amp64binmysqlmysql5.7.23bin bookorama.sql' at line 1
      mysql> source C:wamp64binmysqlmysql5.7.23bin;
      Show warnings disabled.
      ERROR:
      Unknown command 'b'.
      ERROR:
      Unknown command 'm'.
      ERROR:
      Unknown command 'm'.
      ERROR:
      Unknown command 'b'.
      ERROR:
      Failed to open file 'C:amp64binmysqlmysql5.7.23bin', error: 2
      mysql> C:wamp64binmysqlmysql5.7.23binbookorama.sql
      Show warnings disabled.
      ERROR:
      Unknown command 'b'.
      ERROR:
      Unknown command 'm'.
      ERROR:
      Unknown command 'm'.
      ERROR:
      Unknown command 'b'.
      ERROR:
      Unknown command 'b'.
      -> ;
      ERROR 1064 (42000): You have an error in your SQL syntax; check the manual
      that corresponds to your MySQL server version for the right syntax to use
      near 'C:amp64binmysqlmysql5.7.23binbookorama.sql' at line 1
      mysql> mysql -h localhost -u root
      -> ;
      ERROR 1064 (42000): You have an error in your SQL syntax; check the manual
      that corresponds to your MySQL server version for the right syntax to use
      near 'mysql -h localhost -u root' at line 1
      mysql> -h localhost -root -pOscar545* books < bookorama.sql
      -> ;
      ERROR 1064 (42000): You have an error in your SQL syntax; check the manual
      that corresponds to your MySQL server version for the right syntax to use
      near '-h localhost -root -pOscar545* books < bookorama.sql' at line 1
      mysql> mysql -u root -p books < bookorama.sql
      -> ;
      ERROR 1064 (42000): You have an error in your SQL syntax; check the manual
      that corresponds to your MySQL server version for the right syntax to use
      near 'mysql -u root -p books < bookorama.sql' at line 1
      mysql>






      mysql sql windows-10 command-prompt






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Nov 13 '18 at 11:30









      fsuloverfsulover

      34




      34
























          2 Answers
          2






          active

          oldest

          votes


















          1














          At the mysql> prompt you'd use:



          use books;
          source bookorama.sql;


          At the command prompt you'd use:



          mysql.exe -h localhost -root -pOscar545* books < bookorama.sql





          share|improve this answer


























          • sorry, yes, source. mixing languages. :)

            – shawn
            Dec 25 '18 at 20:35



















          0














          The MySQL CLI (command line interface) like other CLIs or shell programs including databases (Postgres' psql, SQLite's sqlite3, SQL Server's sqlcmd, Oracle's sqlplus), langauges (python.exe, perl.exe, php.exe, r.exe), and others are executables (.exe) that do not launch with a GUI like most software .exes but evokes a session inside a terminal window.



          Command line interpreters such as Windows' PowerShell and Cmd.exe, or Unix's (MacOS/Linux) Bash terminal are used to start such CLI sessions. Essentially, there are two ways to run MySQL commands:




          1. Call mysql.exe with arguments without opening prolonged session.


          2. Launch a mysql session and run separate calls.



          Your problem is the conflation of the above two where you are attempting a command line call of mysql.exe with arguments inside mysql.exe or running its top level arguments inside a session. Inside the CLI, the parser only interprets special MySQL commands like source and direct SQL queries not executable, mysql, calls or connection arguments (-h, -u) without its shell command caller: !.



          Simply use appropriate calls outside a CLI session:



          cd C:amp64binmysqlmysql5.7.23bin
          mysql -h localhost -u bookorama -p < bookorama.sql


          Or inside a CLI session:



          cd C:amp64binmysqlmysql5.7.23bin
          mysql -h localhost -u bookorama -p
          mysql> source bookorama.sql




          With that said, you can do the opposite.





          • Running command queries outside:



            mysql -h localhost -u bookorama -p -e "source bookorama.sql"



          • Calling terminal calls inside:



            mysql> ! mysql -h localhost -u bookorama -pXXXXX < bookorama.sql







          share|improve this answer























            Your Answer






            StackExchange.ifUsing("editor", function () {
            StackExchange.using("externalEditor", function () {
            StackExchange.using("snippets", function () {
            StackExchange.snippets.init();
            });
            });
            }, "code-snippets");

            StackExchange.ready(function() {
            var channelOptions = {
            tags: "".split(" "),
            id: "1"
            };
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function() {
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled) {
            StackExchange.using("snippets", function() {
            createEditor();
            });
            }
            else {
            createEditor();
            }
            });

            function createEditor() {
            StackExchange.prepareEditor({
            heartbeatType: 'answer',
            autoActivateHeartbeat: false,
            convertImagesToLinks: true,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: 10,
            bindNavPrevention: true,
            postfix: "",
            imageUploader: {
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            },
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            });


            }
            });














            draft saved

            draft discarded


















            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53280077%2fhow-can-i-execute-an-sql-file-correctly-within-mysql-in-windows-10-command-promp%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown

























            2 Answers
            2






            active

            oldest

            votes








            2 Answers
            2






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            1














            At the mysql> prompt you'd use:



            use books;
            source bookorama.sql;


            At the command prompt you'd use:



            mysql.exe -h localhost -root -pOscar545* books < bookorama.sql





            share|improve this answer


























            • sorry, yes, source. mixing languages. :)

              – shawn
              Dec 25 '18 at 20:35
















            1














            At the mysql> prompt you'd use:



            use books;
            source bookorama.sql;


            At the command prompt you'd use:



            mysql.exe -h localhost -root -pOscar545* books < bookorama.sql





            share|improve this answer


























            • sorry, yes, source. mixing languages. :)

              – shawn
              Dec 25 '18 at 20:35














            1












            1








            1







            At the mysql> prompt you'd use:



            use books;
            source bookorama.sql;


            At the command prompt you'd use:



            mysql.exe -h localhost -root -pOscar545* books < bookorama.sql





            share|improve this answer















            At the mysql> prompt you'd use:



            use books;
            source bookorama.sql;


            At the command prompt you'd use:



            mysql.exe -h localhost -root -pOscar545* books < bookorama.sql






            share|improve this answer














            share|improve this answer



            share|improve this answer








            edited Dec 25 '18 at 20:35

























            answered Dec 25 '18 at 18:50









            shawnshawn

            813




            813













            • sorry, yes, source. mixing languages. :)

              – shawn
              Dec 25 '18 at 20:35



















            • sorry, yes, source. mixing languages. :)

              – shawn
              Dec 25 '18 at 20:35

















            sorry, yes, source. mixing languages. :)

            – shawn
            Dec 25 '18 at 20:35





            sorry, yes, source. mixing languages. :)

            – shawn
            Dec 25 '18 at 20:35













            0














            The MySQL CLI (command line interface) like other CLIs or shell programs including databases (Postgres' psql, SQLite's sqlite3, SQL Server's sqlcmd, Oracle's sqlplus), langauges (python.exe, perl.exe, php.exe, r.exe), and others are executables (.exe) that do not launch with a GUI like most software .exes but evokes a session inside a terminal window.



            Command line interpreters such as Windows' PowerShell and Cmd.exe, or Unix's (MacOS/Linux) Bash terminal are used to start such CLI sessions. Essentially, there are two ways to run MySQL commands:




            1. Call mysql.exe with arguments without opening prolonged session.


            2. Launch a mysql session and run separate calls.



            Your problem is the conflation of the above two where you are attempting a command line call of mysql.exe with arguments inside mysql.exe or running its top level arguments inside a session. Inside the CLI, the parser only interprets special MySQL commands like source and direct SQL queries not executable, mysql, calls or connection arguments (-h, -u) without its shell command caller: !.



            Simply use appropriate calls outside a CLI session:



            cd C:amp64binmysqlmysql5.7.23bin
            mysql -h localhost -u bookorama -p < bookorama.sql


            Or inside a CLI session:



            cd C:amp64binmysqlmysql5.7.23bin
            mysql -h localhost -u bookorama -p
            mysql> source bookorama.sql




            With that said, you can do the opposite.





            • Running command queries outside:



              mysql -h localhost -u bookorama -p -e "source bookorama.sql"



            • Calling terminal calls inside:



              mysql> ! mysql -h localhost -u bookorama -pXXXXX < bookorama.sql







            share|improve this answer




























              0














              The MySQL CLI (command line interface) like other CLIs or shell programs including databases (Postgres' psql, SQLite's sqlite3, SQL Server's sqlcmd, Oracle's sqlplus), langauges (python.exe, perl.exe, php.exe, r.exe), and others are executables (.exe) that do not launch with a GUI like most software .exes but evokes a session inside a terminal window.



              Command line interpreters such as Windows' PowerShell and Cmd.exe, or Unix's (MacOS/Linux) Bash terminal are used to start such CLI sessions. Essentially, there are two ways to run MySQL commands:




              1. Call mysql.exe with arguments without opening prolonged session.


              2. Launch a mysql session and run separate calls.



              Your problem is the conflation of the above two where you are attempting a command line call of mysql.exe with arguments inside mysql.exe or running its top level arguments inside a session. Inside the CLI, the parser only interprets special MySQL commands like source and direct SQL queries not executable, mysql, calls or connection arguments (-h, -u) without its shell command caller: !.



              Simply use appropriate calls outside a CLI session:



              cd C:amp64binmysqlmysql5.7.23bin
              mysql -h localhost -u bookorama -p < bookorama.sql


              Or inside a CLI session:



              cd C:amp64binmysqlmysql5.7.23bin
              mysql -h localhost -u bookorama -p
              mysql> source bookorama.sql




              With that said, you can do the opposite.





              • Running command queries outside:



                mysql -h localhost -u bookorama -p -e "source bookorama.sql"



              • Calling terminal calls inside:



                mysql> ! mysql -h localhost -u bookorama -pXXXXX < bookorama.sql







              share|improve this answer


























                0












                0








                0







                The MySQL CLI (command line interface) like other CLIs or shell programs including databases (Postgres' psql, SQLite's sqlite3, SQL Server's sqlcmd, Oracle's sqlplus), langauges (python.exe, perl.exe, php.exe, r.exe), and others are executables (.exe) that do not launch with a GUI like most software .exes but evokes a session inside a terminal window.



                Command line interpreters such as Windows' PowerShell and Cmd.exe, or Unix's (MacOS/Linux) Bash terminal are used to start such CLI sessions. Essentially, there are two ways to run MySQL commands:




                1. Call mysql.exe with arguments without opening prolonged session.


                2. Launch a mysql session and run separate calls.



                Your problem is the conflation of the above two where you are attempting a command line call of mysql.exe with arguments inside mysql.exe or running its top level arguments inside a session. Inside the CLI, the parser only interprets special MySQL commands like source and direct SQL queries not executable, mysql, calls or connection arguments (-h, -u) without its shell command caller: !.



                Simply use appropriate calls outside a CLI session:



                cd C:amp64binmysqlmysql5.7.23bin
                mysql -h localhost -u bookorama -p < bookorama.sql


                Or inside a CLI session:



                cd C:amp64binmysqlmysql5.7.23bin
                mysql -h localhost -u bookorama -p
                mysql> source bookorama.sql




                With that said, you can do the opposite.





                • Running command queries outside:



                  mysql -h localhost -u bookorama -p -e "source bookorama.sql"



                • Calling terminal calls inside:



                  mysql> ! mysql -h localhost -u bookorama -pXXXXX < bookorama.sql







                share|improve this answer













                The MySQL CLI (command line interface) like other CLIs or shell programs including databases (Postgres' psql, SQLite's sqlite3, SQL Server's sqlcmd, Oracle's sqlplus), langauges (python.exe, perl.exe, php.exe, r.exe), and others are executables (.exe) that do not launch with a GUI like most software .exes but evokes a session inside a terminal window.



                Command line interpreters such as Windows' PowerShell and Cmd.exe, or Unix's (MacOS/Linux) Bash terminal are used to start such CLI sessions. Essentially, there are two ways to run MySQL commands:




                1. Call mysql.exe with arguments without opening prolonged session.


                2. Launch a mysql session and run separate calls.



                Your problem is the conflation of the above two where you are attempting a command line call of mysql.exe with arguments inside mysql.exe or running its top level arguments inside a session. Inside the CLI, the parser only interprets special MySQL commands like source and direct SQL queries not executable, mysql, calls or connection arguments (-h, -u) without its shell command caller: !.



                Simply use appropriate calls outside a CLI session:



                cd C:amp64binmysqlmysql5.7.23bin
                mysql -h localhost -u bookorama -p < bookorama.sql


                Or inside a CLI session:



                cd C:amp64binmysqlmysql5.7.23bin
                mysql -h localhost -u bookorama -p
                mysql> source bookorama.sql




                With that said, you can do the opposite.





                • Running command queries outside:



                  mysql -h localhost -u bookorama -p -e "source bookorama.sql"



                • Calling terminal calls inside:



                  mysql> ! mysql -h localhost -u bookorama -pXXXXX < bookorama.sql








                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Dec 25 '18 at 21:15









                ParfaitParfait

                50k84269




                50k84269






























                    draft saved

                    draft discarded




















































                    Thanks for contributing an answer to Stack Overflow!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid



                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.


                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function () {
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53280077%2fhow-can-i-execute-an-sql-file-correctly-within-mysql-in-windows-10-command-promp%23new-answer', 'question_page');
                    }
                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    Popular posts from this blog

                    Xamarin.iOS Cant Deploy on Iphone

                    Glorious Revolution

                    Dulmage-Mendelsohn matrix decomposition in Python