sixtysticks
sixtysticks

Reputation: 826

Copying MySQL database from test server to local MAMP server

I may have gone completely braindead today, but I'm having trouble copying my DB down to my local MAMP server. I'm not too familiar with mysqldump, etc, but I want to know how to copy a database from a test server to my MAMP local server in the easiest way possible. I have very limited experience with server stuff, but have a bit of experience with command line.

Any straight-forward help would be much appreciated. I look forward to smacking myself in the head when I realise what a dick I've been ;)

Dalogi

Upvotes: 1

Views: 2791

Answers (2)

Gary
Gary

Reputation: 421

mysqldump -h 'remotehost' -uremoteuser -premotepass db_name | mysql -ulocaluser -plocalpass db_name

Upvotes: 2

Marc B
Marc B

Reputation: 360762

mysqldump's the best way:

on the test server: mysqldump -p name_of_db > dump.sql
on the map server: mysql -p < dump.sql

The dump file contains the full instructions in SQL query format to recreating the db, it stable structure, and data. The -p option forces both apps to prompt for your password. If your MySQL username is different than your system's login account, then you'll need the -u option as well:

mysqldump -p -u yourDBusername name_of_db > dump.sql
mysql -p -u yourDBusername < dump.sql

Upvotes: 4

Related Questions