View Full Version : SQL Dump File?
ijasont
04-04-2003, 10:36 AM
I hate to push my luck after yesterdays field day of help but this should be an easy one.
I am following a tutorial that says:
mysql> CREATE DATABASE news;
3. Create the database tables using the dump file:
$ mysql -u <username> -p <password> -D <database> < news.sql
I know how to create a database no problem. But "news.sql" was included in the dloaded folder and I think the BOLDED line means to import or 'dump' that file into the one I already created.
I do not understand the directions for this. Could someone please let me a hand?
griffman
04-04-2003, 11:22 AM
In your example, just type:
mysql -u mysql_username -pmysql_password -D news < news.sql
The datbase you created is simply a blank database. MySQL needs the database to exist before you can do anything to it. The command above will take an SQL file that contains a set of table and field defintions, as well as some data (most likely) and import them into the empty database you just created.
Note that there is no space between the "-p" and your password (at least, on my machine it won't work if there is). You can also just enter "-p" and it should prompt you for the password when you hit Enter.
-rob.
ijasont
04-04-2003, 11:36 AM
Thanks for the help.
I don't seem to be able to get it right.
There should be a way to just do this through phpMyAdmin or something.
I keep getting syntax errors when I try it.
Oh well, I'll just move to a different tutorial.
Thanks again for your help!!!
Jason
griffman
04-04-2003, 11:39 AM
Can you copy and paste some of your terminal output here? Just remember to change the username/password bit...
Make sure you're in the directory with the SQL file.
There is a way to do this through phpMyAdmin via the SQL tab. Just point it at the SQL text file, and it should work. Can't say I've tried it myself, though.
-rob.
ijasont
04-04-2003, 11:49 AM
OK I did'nt know you had to be in the directory, I was in the mysql prompt.
So I went to the directory then typed;
[12-247-28-255:Webserver/Documents/news] jason% mysql -u jason -p -D news < news.sql
mysql: Command not found.
griffman
04-04-2003, 11:55 AM
Yea, this is a UNIX command line entry, not a MySQL command.
Seems like MySQL isn't on your path -- type "which mysql" and see if it finds anything. If it doesn't, try typing "/usr/local/mysql/bin/mysql" instead of just mysql.
-rob.
ijasont
04-04-2003, 12:07 PM
yep that was teh problem!
It worked fine and I imported the news.sql file fine.
This would also explain why sudo mysql (to start mysql) would not work.
You are the BEST!
Jason
griffman
04-04-2003, 12:16 PM
You'll probably want to add the path to mysql to your path; unfortunately, I'm not a tcsh shell wizard, so I can't really explain how to do that (there are a number of options, if I recall correctly).
Maybe someone more versed than I can chime in with some path help...
-rob.
vBulletin® v3.8.4, Copyright ©2000-2010, Jelsoft Enterprises Ltd.