Forum Moderators: open
I've been working on my latest site on my laptop. All is well, the database is quite big and now contains some data.
I want to move the database onto my production server now but have no idea how to do it. On past projects the database has only been very small with no data that I wanted to keep, so I just recreated the database by hand as it only took a few minutes.
Is there a tool that can export this on my laptop, and then import on the other server?
mysqldump -h $db_host --user=$sql_login --password=$sql_pass $db_name > mybackup.sql
Move mybackup.sql to your server.
On your server, create the database and user, log into mysql, switch to the database (use database;) then type
source path/to/mybackup.sql
Will recreate all tables and import the data.
Except that I usually add --opt after mysqldump, which does things like "Include all MySQL specific create options" (see man mysqldump).
Also you can import the new db on the command line on the remote server with
mysql -u $sql_login -p dbname < mybackup.sql
(you'll be prompted for the password)
p.s.
Note that I think you can do this stuff in PHPMyAdmin if you're not comfortable with the command line.