How to export database and download to localhost from EC2

You have the pem file and want to connect to server, export database then need to download it to your machine in localhost.
Ok. Let’s go!

Step 1

Connect to your server use pem file.

ssh -i ./name_file.pem [email protected]

The xxx.xxx.xxx.xxx what is your IP address.

Step 2

Dump databse to sql file.

mysqldump -udb_user -p db_name > sql_export_file_name.sql

db_user: is your database user name
db_name: is your database name in mysql
sql_export_file_name: free with your set

Command will ask you about your databse user password. Please enter and wait for momment to export.

Step 3

Zip file sql for downloading.

gzip -f sql_export_file_name.sql

Step 4

Download to localhost.

Open your terminal in PC to connect and download.

scp -i "name_file.pem" [email protected]://home/ec2-user/sql_export_file_name.sql.gz .

It’s done.

Come back your server connect and remove that file if you want
rm -rf sql_export_file_name.sql.gz

0 0 đánh giá
Đánh giá bài viết
Theo dõi
Thông báo của
guest

0 Góp ý
Phản hồi nội tuyến
Xem tất cả bình luận

More Post

MySQL Procedure là gì?

Procedure trong MySQL là một tập các khai báo sql được lưu trữ trong cơ sở dữ liệu(database) thực...

Dependency Injection và Service Container trong Laravel

Service Container trong Laravel như là trung tâm của một ứng dụng, có mặt mọi nơi trong dự án,...

Laravel Swagger là gì? Hướng dẫn tạo Swagger trong Laravel

Swagger là một framework giúp bạn định nghĩa, mô tả các API trong dự án một cách trực quan, rõ...

2
0
Rất thích suy nghĩ của bạn, hãy bình luận.x