title: How Can I Execute an SQL File Correctly Within MySQL in Windows 10 Command Prompt?
body: <p>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.</p>
  
  <p>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?</p>
  
  <p>Here is my file path to the bookorama.sql file that I am trying to execute:
  C:\wamp64\bin\mysql\mysql5.7.23\bin</p>
  
  <p>The bookorama.sql is within the file path at the last 'bin' folder.</p>
  
  <p>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.</p>
  
  <p><a href="https://stackoverflow.com/questions/30812866/cant-run-mysql-from-command-prompt">Can&#39;t run MySQL from command prompt</a></p>
  
  <p><a href="https://stackoverflow.com/questions/22649118/executing-a-sql-file">Executing a SQL file</a></p>
  
  <p><a href="https://stackoverflow.com/questions/17666249/how-to-import-an-sql-file-using-the-command-line-in-mysql/17666285">How to import an SQL file using the command line in MySQL?</a></p>
  
  <p><a href="https://stackoverflow.com/questions/27236834/execute-sql-file-using-command-line">execute .sql file using command line</a></p>
  
  <p><a href="https://tecadmin.net/run-sql-text-file-on-mysql-command-prompt/" rel="nofollow noreferrer">https://tecadmin.net/run-sql-text-file-on-mysql-command-prompt/</a></p>
  
  <p>Here's a copy of the command prompt tries to execute the sql file:</p>
  
  <pre><code>C:\wamp64\bin\mysql\mysql5.7.23\bin&gt;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&gt; use books
  Database changed
  mysql&gt; -u bookorama -d books &lt; bookoroma.sql
      -&gt; ;
  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 &lt; bookoroma.sql' at line 1
  mysql&gt; mysql
      -&gt; ;
  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&gt; mysql -h localhost - u bookorama -p &lt; bookorama.sql
      -&gt; ;
  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 &lt; bookorama.sql' at line 1
  mysql&gt; cd..
      -&gt; ;
  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&gt; mysql -h localhost -u bookorama -D books -p &lt; bookorama.sql
      -&gt;
      -&gt; CREATE TABLE Customers
      -&gt; ;
  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 &lt; bookorama.sql
  
  CREATE TABLE Custom' at line 1
  mysql&gt; -u bookorama -D books -P &lt; bookorama.sql
      -&gt; ;
  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 &lt; bookorama.sql' at line 1mysql&gt; -u root
      -&gt; -p Oscar545* -D bookorama &lt; bookorama.sql
      -&gt; ;
  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 &lt; bookorama.sql' at line 1
  mysql&gt; mysql -h localhose u-root -D bookorama &lt; 
  C:\wamp64\bin\mysql\mysql5.7.23\bin.bookorama.sql
  Show warnings disabled.
  ERROR:
  Unknown command '\b'.
  ERROR:
  Unknown command '\m'.
  ERROR:
  Unknown command '\m'.
  ERROR:
  Unknown command '\b'.
      -&gt; ;
  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 &lt; 
  C:amp64\bin\mysql\mysql5.7.23\bin.booko' at line 1
  mysql&gt; mysql -h localhose u-root -D bookorama &lt; bookorama.sql
      -&gt; ;
  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 &lt; bookorama.sql' at line 1
  mysql&gt; mysql -u root -p books &lt; bookorama.sql
      -&gt; ;
  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 &lt; bookorama.sql' at line 1
  mysql&gt; use books
  Database changed
  mysql&gt; mysql -u root -p books &lt; bookorama.sql
      -&gt; ;
  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 &lt; bookorama.sql' at line 1
  mysql&gt; C:\wamp64\bin\mysql\mysql5.7.23\bin bookorama.sql
  Show warnings disabled.ERROR:
  Unknown command '\b'.
  ERROR:
  Unknown command '\m'.
  ERROR:
  Unknown command '\m'.
  ERROR:
  Unknown command '\b'.
      -&gt; ;
  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:amp64\bin\mysql\mysql5.7.23\bin bookorama.sql' at line 1
  mysql&gt; source C:\wamp64\bin\mysql\mysql5.7.23\bin;
  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:amp64\bin\mysql\mysql5.7.23\bin', error: 2
  mysql&gt; C:\wamp64\bin\mysql\mysql5.7.23\bin\bookorama.sql
  Show warnings disabled.
  ERROR:
  Unknown command '\b'.
  ERROR:
  Unknown command '\m'.
  ERROR:
  Unknown command '\m'.
  ERROR:
  Unknown command '\b'.
  ERROR:
  Unknown command '\b'.
      -&gt; ;
  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:amp64\bin\mysql\mysql5.7.23\bin\bookorama.sql' at line 1
  mysql&gt; mysql -h localhost -u root
      -&gt; ;
  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&gt; -h localhost -root -pOscar545* books &lt; bookorama.sql
      -&gt; ;
  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 &lt; bookorama.sql' at line 1
  mysql&gt; mysql -u root -p books &lt; bookorama.sql
      -&gt; ;
  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 &lt; bookorama.sql' at line 1
  mysql&gt;
  </code></pre>