Question

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

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.

Subscribe
Share

Thank you very much. I got it done. You’re awesome.

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

Submit an answer
You can type!ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

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.

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