Question

how to import exist mysql database to ubunto server ?

Posted August 26, 2021 85 views
MySQLUbuntu 20.04

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

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.

×
Submit an Answer
1 answer

Hello, @tarekhussien53

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

  • 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

by Mateusz Papiernik
Being able to import and export your database is an important skill to have. You can use data dumps for backup and restoration purposes, so you can recover older copies of your database in case of an emergency, or you can use them to migrate data to a new server or development environment. This tutorial will cover how to export the database as well as import it from a dump file in MySQL and MariaDB.