how to get db backup from digital ocean and i am using mac system. I tried the below command in console but i did not got.
mysqldump -u root -p mydatabse > /var/www/html/sql-data
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!
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.
Heya,
To Export a database, open up terminal, making sure that you are not logged into MySQL and type,
The database that you selected in the command will now be exported to your droplet.
https://www.digitalocean.com/community/tutorials/how-to-import-and-export-databases-and-reset-a-root-password-in-mysql
Additionally, you can also use a GUI like MySQL Workbench or phpMyAdmin to export the database without using the console, if of course, this is more convenient for you.
Regards
Hi there,
Is your MySQL instance running on your Droplet or are you using a Managed Database cluster?
If you are using a Managed Database cluster, you can follow the steps here:
If your MySQL server is running on your Droplet, you need to follow these steps:
First, you need to SSH into your DigitalOcean server where your MySQL database is hosted. Open Terminal on your Mac and use the SSH command:
Replace
username
with your server username andyour_server_ip
with the IP address of your DigitalOcean server.Once logged in, you can use the
mysqldump
command to export your database. The command you used is mostly correct, but you’ll need to adjust the output path to a location on the server where you have write permissions (not/var/www/html/sql-data
unless you specifically need it there and have the right permissions). For example:Replace
mydatabase
with the name of your database. You will be prompted to enter the root password for MySQL.After exporting the database to a
.sql
file on the server, you need to transfer it to your Mac. You can usescp
(secure copy) for this. Run the following command from the Terminal on your Mac, not on the server:Replace
/path/to/mydatabase.sql
with the full path to the SQL file on your server, and/local/path
with the path on your Mac where you want to save the backup.If you want to import this backup into a MySQL database on your Mac, you can use the following command:
This creates a new database (
mylocaldb
) and imports the data from the backup file into it.Remember to replace the placeholders (
username
,your_server_ip
,mydatabase
,mylocaldb
,/path/to/
,/local/path
) with your actual data.Let me know if you have any questions!
Best,
Bobby
Heya @mrjasminchande,
You should try modifying the command a little bit:
Put .sql at the end of the file you wish to save so that it’s considered an SQL file.
Additionally, what happened when you ran the command?