meenasamo
By:
meenasamo

How do I insert data from local database to the new database with tables that I have just created in command line?

June 12, 2015 1.4k views
MySQL DigitalOcean PHP Ubuntu

In my local database, I have hundreds of data and it would be a worrisome for me if I have to insert all over again one by one. Is there any way I export the local data mysql to the server database so my website (php) can display those data.
Please help and I would be really grateful.
Thank you.

2 comments
  • For your local database you can do this:

    mysqldump  --user=YOURMYSQLUSER --password=YOURPASSWORD  --host=localhost YOURDATABASE > thedata.sql
    

    which will create a data file with all of your data.
    then, upload that file to your server (your users home directory), and then run this command:

    mysql --user=YOURMYSQLUSER --password=YOURPASSWORD  --host=localhost YOURDATABASE < thedata.sql
    
  • Thank you very much. I got it done. You're awesome.

1 Answer

This question was answered by @sierracircle:

For your local database you can do this:

mysqldump  --user=YOURMYSQLUSER --password=YOURPASSWORD  --host=localhost YOURDATABASE > thedata.sql

which will create a data file with all of your data.
then, upload that file to your server (your users home directory), and then run this command:

mysql --user=YOURMYSQLUSER --password=YOURPASSWORD  --host=localhost YOURDATABASE < thedata.sql

View the original comment

Have another answer? Share your knowledge.