title: Best place for .sql data and method for retrieving them in mysql database?
body: <p>I have some confusion with .bash_profile, terminal, MAMP and MySQL Workbench.</p>
  
  <p>My goal is to load .sql data files into a database from terminal. Working on tutorials from Paul Dubois' book on MySQL. The Appendix A says to add a PATH setting to .bash_profile:</p>
  
  <pre><code>PATH=/usr/local/mysql/bin:/bin:/usr/bin:/usr/local/bin
  </code></pre>
  
  <p>I added the above path to the .bash_profile. Although in the first chapter it says a folder of sample .sql files called (sampdb) can be located anywhere. So I tried: </p>
  
  <pre><code>export PATH="/Users/trevorpan/Documents/MySQL/sampdb:$PATH"
  </code></pre>
  
  <p>Adding this PATH did not find the file with this command: </p>
  
  <pre><code>mysql&gt; sampdb &lt; create_grade_event.sql;
  </code></pre>
  
  <p>It gave me this error. And I feel it must be related to the path, because all over stack overflow, the book, and the online MySQL manual say the above is the proper syntax.</p>
  
  <pre><code>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 'sampdb &lt; create_grade_event.sql' at line 1
  </code></pre>
  
  <p>I also tried:</p>
  
  <pre><code>mysql&gt; source create_grade_event.sql;
  ERROR: 
  Failed to open file 'create_grade_event.sql', error: 2
  </code></pre>
  
  <p>This didn't work either.</p>
  
  <p>Now, I'm thinking the files should just go in the bin folder. But I'm not sure if they should stay in the folder (sampdb) or what.</p>
  
  <p>Here's the .bash_profile:</p>
  
  <pre><code>export PATH=/Applications/MAMP/bin/php/php7.1.12/bin:/usr/local/opt/gnu-tar/lib$
  export MAMP_PHP=/Applications/MAMP/bin/php/php7.1.12/bin
  export PATH="$MAMP_PHP:$PATH"
  ICU_DIR=/usr/local/Cellar/icu4c/60.2/
  EXT_DIR=/Applications/MAMP/bin/php/php7.1.12/lib/php/extensions/no-debug-non-zt$
  
  if [ -f ~/.bashrc ]; then
          source ~/.bashrc
  fi
  
  export PATH="/usr/local/opt/m4/bin:$PATH"
  PATH=/usr/local/mysql/bin:/bin:/usr/bin:/usr/local/bin
  </code></pre>
  
  <p>Thank you.</p>
  
  <p><strong>EDIT</strong>:</p>
  
  <p>I tried dragging a file to terminal and had success.</p>
  
  <pre><code>mysql&gt; source /Applications/MAMP/bin/sampdb/insert_member.sql 
  Query OK, 0 rows affected (0.05 sec)
  
  Query OK, 1 row affected (0.02 sec)
  
  Query OK, 1 row affected (0.00 sec)
  
  Query OK, 1 row affected (0.04 sec)
  
  Query OK, 1 row affected (0.01 sec) etc. etc.
  </code></pre>
  
  <p><strong>EDIT #2</strong></p>
  
  <p>aha. Michael,</p>
  
  <p>I tried changing the directory and received this error. cd is not able to point to a directory while mysql is loaded in terminal, so I'm unsure the method you use to load it from a current directory:</p>
  
  <pre><code>mysql&gt; cd /Applications/MAMP/bin/sampdb;
  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 /Applications/MAMP/bin/sampdb' at line 1
  </code></pre>
  
  <p>My goal is to point to a folder location and be able to upload .sql data files without having to enter the path each time. The following post had a similar issue, but it never seemed to resolve the simple import command of: </p>
  
  <pre><code>mysql&gt; source create_grade_event.sql
  </code></pre>
  
  <p><a href="https://stackoverflow.com/questions/17666249/how-to-import-an-sql-file-using-the-command-line-in-mysql">How to import an SQL file using the command line in MySQL?</a></p>
  
  <p>My original post name was trying to get to that. Should the .sql data files be placed in bin? If so, how do I direct mysql to load them with a query like above? Is there a better place you use to store project .sql files?</p>
  
  <p>Thank you.</p>