Page 1 of 1

creating database using dump file

Posted: Thu Aug 29, 2002 4:42 am
by ridwan
Hi all;

I am trying to create a database using a dump file, but am not too sure how to do it.

1)I know/think that this is the command I have to use :
mysql> mysql -u <username> -p <password> -D <database> < news.sql

but it doesn't seem to work and just spits out errors.

2)where do i put my news.sql file

thanks

Posted: Thu Aug 29, 2002 4:57 am
by sunderwind
I would guess that the dump file does not contain the create database <database> (You have to provide a special switch when making the dumpfile to get this)

Create the database first. Either log into mysql and "create database <DB>" or use "echo 'create database <DB> | mysql -u <username> -p <password>" or use "mysqladmin -u <username> -p <password> create <DB>"

If you already have a database named the same and it contains data, you will probably need to drop it, recreate it, and then load the dump.

After you have created the database do what you tried before.

Posted: Thu Aug 29, 2002 7:29 am
by volka
mysql -u <username> -p <password> -D <database> < news.sql
But do not run this command from within the mysql-client but in the shell/commandline.