Muhammad Usama
Beyond DevOps

Follow

Beyond DevOps

Follow
Importing and Exporting Data in MySQL

Importing and Exporting Data in MySQL

Muhammad Usama's photo
Muhammad Usama
·Feb 11, 2023·

1 min read

Exporting Data in MySQL

The MySQL terminal provides a simple way to export data in SQL format using the following command:

mysqldump -u [username] -p [database name] > [file name].sql

For example, to export the database katra using the username app__db_user, you would use the following command, mydb_backup.sql will be your backup file of database katra

After running this command it will prompt you for your Mysql user app_db_user password

mysqldump -u app__db_user -p katra > mydb_backup.sql

Importing Data in MySQL

The following command can be used to import an SQL file:

mysql -u [username] -p [database name] < [file name].sql

For example, to import the "mydb_backup.sql" file using the username app_db_user, and the database mydb you would use the following command: we can also define host option -h if you are using hosted Database

mysql -u root -p mydb < mydb_backup.sql

Note: For importing to Database please make sure the user you are using has access

 
Share this