creating database using dump file

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
ridwan
Forum Commoner
Posts: 55
Joined: Thu Aug 22, 2002 3:15 am

creating database using dump file

Post 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
sunderwind
Forum Newbie
Posts: 9
Joined: Thu Aug 29, 2002 4:24 am
Location: Irving, TX
Contact:

Post 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.
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post 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.
Post Reply