Question

how to import exist mysql database to ubunto server ?

Hello my friends, I have a data-dump.sql file on my desktop and I want to upload it to an empty database on the Ubuntu server of Digital Ocean. What are the commands for that? Note that I searched a lot but could not find a solution for it. Thank you


Submit an answer

This textbox defaults to using Markdown to format your answer.

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

Sign In or Sign Up to Answer

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.

Want to learn more? Join the DigitalOcean Community!

Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in Q&A, subscribe to topics of interest, and get courses and tools that will help you grow as a developer and scale your project or business.

Hello, @tarekhussien53

From the normal command line, you can import the dump file with the following command:

  1. mysql -u username -p new_database < data-dump.sql
  • username is the username you can log in to the database with
  • newdatabase is the name of the freshly created database
  • data-dump.sql is the data dump file to be imported, located in the current directory

You can check our tutorial on How To Import and Export Databases in MySQL or MariaDB

https://www.digitalocean.com/community/tutorials/how-to-import-and-export-databases-in-mysql-or-mariadb

Regards, Alex