Question

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

Posted June 12, 2015 2.8k views
UbuntuMySQLPHPDigitalOcean

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.

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

×
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

Submit an Answer