How to export mysql database with terminal

Hello Everyone

I want to get (export) mysql database , i cant use this url because does not exists i have already installed phpmyadmin in terminal but there is nothing, so i decide to export database from terminal , do anybody knows how to export mysql database from terminal

i used this code mysql -u [username] -p newdatabase < [database name].sql

maybe a database exported but where is that files location dont know :/ i want just sql file


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.


Thank you so much, you really helped me.

Hi @levan100

The code example you’ve supplied is for importing data - not exporting.

You should use mysqldump, since it tries to do the data dump without blocking the database tables.

mysqldump -u [username] -p [database-you-want-to-dump] > [path-to-place-data-dump]

So it could be something like this:

mysqldump -u root -p mydatabase > /home/myuser/database-dump.sql

Then the database dump would be /home/myuser/database-dump.sql

You can read more about mysqldump here: