Export a database

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
micknic
Forum Commoner
Posts: 37
Joined: Thu Feb 27, 2003 1:27 pm
Location: belgium

Export a database

Post by micknic »

I created a database of six tables for an intranet. Now I would like to export this database to the server. How to do?? Do I just have to copy the MYI, MYD and FRM files on the server???

Thank you very much
User avatar
daven
Forum Contributor
Posts: 332
Joined: Tue Dec 17, 2002 1:29 pm
Location: Gaithersburg, MD
Contact:

Post by daven »

What type of DB are you using? MySQL, PostGreSQL, MS-SQL, Oracle, etc?
micknic
Forum Commoner
Posts: 37
Joined: Thu Feb 27, 2003 1:27 pm
Location: belgium

Post by micknic »

I use a MySQL database. I hope you can help e
User avatar
haagen
Forum Commoner
Posts: 79
Joined: Thu Jul 11, 2002 3:57 pm
Location: Sweden, Lund

Post by haagen »

It's simple.

You have to use a programm called mysqldump.

Så on your development machine you'll write

mysqldump databasename > scriptfile.sql

And on your intranetserver you write.

mysqladmin create databasename
cat scriptfile.sql | mysql databasename

I assume you use Unix. But I assume thate the mysqldump program is included in the windows dist as well.

Read the manual for mysqldump, it can bu configured not to include data and just the schema and so on.

Good Luck!
ckuipers
Forum Commoner
Posts: 61
Joined: Mon Mar 24, 2003 6:10 am

Post by ckuipers »

This is what I usually do:

mysqldump --opt -u username --password=yourpass database > backup-file.sql
You can read this back into MySQL with:

mysql -u username --password=yourpass database < backup-file.sql


Make sure you don't put a space between the '=' and 'yourpass' otherwise it won't work.
Post Reply