ricem84 Posted January 29, 2009 Share Posted January 29, 2009 I've been learning mysql for 2 days now, so my title may be inaccurate when it comes to the problem I will describe. I'm not even sure what to call it. I am reading the book, PHP and MySQL Web Development. I have entered the description of the tables by hand (because I couldn't get an sql file to read earlier in the book) to make some tables that represent book orders. This next file I can't read is for adding entries to those tables. I have MySQL Server 5.0. The book says to use the file I should type mysql -h host -u bookorama -p books < /path/to/book_insert.sql; I typed in (ignoring -h host because the host is on the same computer I am using and using c:/book_insert.sql for where the file is stored): mysql -u bookorama -p books <c:/book_insert.sql ; I get the 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 bookorama -p books < c:/book_insert.sql' at line 1. My database is called "books." I have tried typing in similar things but none of them worked. Anyone have an idea what I'm typing in that's wrong? I'd look it up in the manual but I'm not even sure how to find the syntax. Quote Link to comment https://forums.phpfreaks.com/topic/142927-solved-trouble-reading-sql-file-into-tables/ Share on other sites More sharing options...
fenway Posted January 29, 2009 Share Posted January 29, 2009 Post some sample data from the .sql file. Quote Link to comment https://forums.phpfreaks.com/topic/142927-solved-trouble-reading-sql-file-into-tables/#findComment-749392 Share on other sites More sharing options...
Mchl Posted January 29, 2009 Share Posted January 29, 2009 You don't type those into MySQL console, do you? mysql -h host -u bookorama -p books < /path/to/book_insert.sql This is to be typed into system command line (Menu Start > Run > type in 'cmd' and press enter) Quote Link to comment https://forums.phpfreaks.com/topic/142927-solved-trouble-reading-sql-file-into-tables/#findComment-749416 Share on other sites More sharing options...
FezEvils Posted January 29, 2009 Share Posted January 29, 2009 better fro you to download mysql console such as xampp (sourceforge.net/projects/xampp/) or navicat (http://www.navicat.com/) then all you need is import the sql file or paste it... settle lor Quote Link to comment https://forums.phpfreaks.com/topic/142927-solved-trouble-reading-sql-file-into-tables/#findComment-749421 Share on other sites More sharing options...
Mchl Posted January 29, 2009 Share Posted January 29, 2009 You know... some people want to learn basics as well Quote Link to comment https://forums.phpfreaks.com/topic/142927-solved-trouble-reading-sql-file-into-tables/#findComment-749423 Share on other sites More sharing options...
FezEvils Posted January 29, 2009 Share Posted January 29, 2009 haha.. that right, but to learn the basic , it will take a long time . and the result is small... anyway gudluck with the command line Quote Link to comment https://forums.phpfreaks.com/topic/142927-solved-trouble-reading-sql-file-into-tables/#findComment-749432 Share on other sites More sharing options...
ricem84 Posted January 29, 2009 Author Share Posted January 29, 2009 This is the file: use books; insert into customers values (3, "Julie Smith", "25 Oak Street", "Airport West"), (4, "Alan Wong", "1/47 Haines Avenue", "Box Hill"), (5, "Michelle Arthur", "357 North Road", "Yarraville"); insert into orders values (NULL, 3, 69.98, "2007-04-02"), (NULL, 1, 49.99, "2007-04-15"), (NULL, 2, 74.98, "2007-04-19"), (NULL, 3, 24.99, "2007-05-01"); insert into books values ("0-672-31697-8", "Michael Morgan", "Java 2 for Professional Developers", 34.99), ("0-672-31745-1", "Thomas Down", "Installing Debian GNU/Linux", 24.99), ("0-672-31509-2", "Pruitt, et al.", "Teach Yourself GIMP in 24 Hours", 24.99), ("0-672-31769-9", "Thomas Schenk", "Caldera OpenLinux System Administration Unleashed", 49.99); insert into order_items values (1, "0-672-31697-8", 2), (2, "0-672-31769-9", 1), (3, "0-672-31769-9", 1), (3, "0-672-31509-2", 1), (4, "0-672-31745-1", 3); insert into book_reviews values ("0-672-31697-8", "Morgan's book is clearly written and goes well beyond most of the basic Java books out there."); I don't know where Run is on Vista, so I search for cmd and login (msql -u bookorama -p) to log in. One problem I'm having is that I don't know which way /'s go in addresses. Is it / or \? Quote Link to comment https://forums.phpfreaks.com/topic/142927-solved-trouble-reading-sql-file-into-tables/#findComment-749901 Share on other sites More sharing options...
Mchl Posted January 29, 2009 Share Posted January 29, 2009 The worse way ( \ ). To help you remember, it's the other way than it is in internet addresses. Oh.. and in Vista you just need to type 'cmd' into search box in Start Menu Quote Link to comment https://forums.phpfreaks.com/topic/142927-solved-trouble-reading-sql-file-into-tables/#findComment-749904 Share on other sites More sharing options...
ricem84 Posted January 29, 2009 Author Share Posted January 29, 2009 Is it because I'm typing the load stuff file from mysql> line instead of the cmd line? Quote Link to comment https://forums.phpfreaks.com/topic/142927-solved-trouble-reading-sql-file-into-tables/#findComment-749949 Share on other sites More sharing options...
Mchl Posted January 29, 2009 Share Posted January 29, 2009 Yes. That's what I was telling you. Quote Link to comment https://forums.phpfreaks.com/topic/142927-solved-trouble-reading-sql-file-into-tables/#findComment-749973 Share on other sites More sharing options...
ricem84 Posted January 29, 2009 Author Share Posted January 29, 2009 Oops. My bad. I read your post; I just didn't really process it, which would have saved me a lot of trouble. I was just so under the impression that everything in mysql had to be done with mysql> lines. But it works now! I'm glad I took the time to figure it out and ask people rather than typing every sql file in by hand. Thanks! Quote Link to comment https://forums.phpfreaks.com/topic/142927-solved-trouble-reading-sql-file-into-tables/#findComment-750097 Share on other sites More sharing options...
Mchl Posted January 30, 2009 Share Posted January 30, 2009 Now that you know that, you might indeed try some GUI to spare you typing Quote Link to comment https://forums.phpfreaks.com/topic/142927-solved-trouble-reading-sql-file-into-tables/#findComment-750500 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.