How to Export MySQL Database Using Command Line in Ubuntu

Reading Time: 3 minutes
5,109 Views

Inside this article we will see how to export mysql database using command line in ubuntu operating system. Tutorial will be super easy to understand.

When you have a large size of database then we can not easily export from phpmyadmin or any other tool. So in that case we need to use mysql commands for it. Here, we will see a simple command to export large size database using command in ubuntu.

We can export mysql database in several ways. But in this tutorial we will use a command which will be executed from terminal in ubuntu.

Learn More –

Let’s get started.


Manual PhpMyAdmin Interface For Export

If we have a small size database, then instead of using command we can go ahead with the manual phpmyadmin interface.

But if we have large size database or say export manual tool is not working then in these cases we can use command line.


MySQL Export Database via Interactive Mode

Inside this case we are going to use terminal and few commands of mysql to use MySQL interactive mode.

Also here, we have multiple options to choose file formats for export. We will use .sql to understand.

Export Data From MySQL Specific Table

Syntax:

$ mysqldump -u {username} -p {database_name} {table_name} > {file_path}

Example:

$ mysqldump -u root -p db_management tbl_roles > /var/www/html/dbt/roles.sql

Table data will be exported to roles.sql file and saved to the specified path.

Export Compete database From MySQL

Syntax:

$ mysqldump -u {username} -p {database_name} > {file_path}

Example:

$ mysqldump -u root -p db_management > /var/www/html/dbt/data.sql

db_management database will be exported to data.sql file and will save at given location.

We hope this article helped you to learn about How to Export Mysql Database Using Command Line in Ubuntu in a very detailed way.

Online Web Tutor invites you to try Skillshike! Learn CakePHP, Laravel, CodeIgniter, Node Js, MySQL, Authentication, RESTful Web Services, etc into a depth level. Master the Coding Skills to Become an Expert in PHP Web Development. So, Search your favourite course and enroll now.

If you liked this article, then please subscribe to our YouTube Channel for PHP & it’s framework, WordPress, Node Js video tutorials. You can also find us on Twitter and Facebook.

Sanjay KumarHello friends, I am Sanjay Kumar a Web Developer by profession. Additionally I'm also a Blogger, Youtuber by Passion. I founded Online Web Tutor and Skillshike platforms. By using these platforms I am sharing the valuable knowledge of Programming, Tips and Tricks, Programming Standards and more what I have with you all. Read more