By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,952 Members | 1,908 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,952 IT Pros & Developers. It's quick & easy.

MySQL 5.5 execution of sql file using "source"

P: 2
Greetings,

I'm trying to execute a sql file in the command line for sql 5.5 on a windows 7 computer. My sql file is on my c drive in the directory "john". My sql file is named mysql-start.sql. How do I execute the source command to run this sql file? This is something I am learning from a free online database class from Stanford. Here is how the class suggests I do this:

To try executing a SQL file from the command-line shell, download the starter script, place it somewhere that you can easily remember the file path, and type the following at the prompt (where ~PATH~ represents the path to the file):

mysql> source '~PATH~/mysql-start.sql'

I have tried the above to no avail.Any help is greatly appreciated,

John M
Oct 18 '11 #1
Share this Question
Share on Google+
3 Replies


100+
P: 1,059
The statement is
Expand|Select|Wrap|Line Numbers
  1. mysql> \. c:/john/mysql-start.sql
before you do you should read link first
Oct 18 '11 #2

P: 2
Thanks for the reply!

I tried \. c:/john/mysql-start.sql , and i get "error 1046 <3D000>: No database selected". Here are the contents of the mysql-start.sql file:
drop table if exists T;
create table T (A text, B text);
insert into T values ('Hello,', 'world!');
select * from T;

Thanks again! Any ideas?

John M
Oct 18 '11 #3

Rabbit
Expert Mod 10K+
P: 12,347
Well, from the error, it sounds like you didn't select a database. You can't run SQL without selecting a database first.
Oct 18 '11 #4

Post your reply

Sign in to post your reply or Sign up for a free account.