How To Export Large Mysql Database Using Command Line
Hello Friends,
Let's learn about some MySQL tips, tricks, and hacks. As we all know we can import or export databases from MySQL. Most of us use tools like PHPMyAdmin or Adminer to export or import data from MySQL.
But today we will use the command line interface to export the MySQL database. We will export the data without any external tool or plugin.
Why use Commands to export the database?
As we all know we can use tools like PHPMyAdmin to export the database or table. But sometimes we don't have access to MySQL or the data is very big in size. We can face many issues if the database size is large. like timeout errors or memory limits.
Then we must have to use commands to export data. So, Today I will give you a simple but helpful example to export the data with commands.
Syntax
mysqldump -u username -p database_name > data-dump.sql
Export database
Let's see how we can export the database with an example.
mysqldump -u root -p school >school.sql
Export Selected tables
mysqldump -u root -p school students teachers > file_name
In this example school is the database. students and teachers are the table name.
Export Multiple database
mysqldump -u root -p ---databases school store hospital > file_name
In this method, we can export multiple databases at a time.
Ignore selected tables to export
mysqldump -u root -p school --ignore-table=school.fees > file_name
That's all for this post. I hope this post is helpful to use.
Please share this post with your friends.
Don't forget to follow are social handlers for more updates.
Thanks