Professional Documents
Culture Documents
How To ExportImport A MySQL Database Via SSH in AWS Lightsail
How To ExportImport A MySQL Database Via SSH in AWS Lightsail
Suppose you want a database backup of any instances ‘ in AWS Lightsail WordPress ‘
through putty or SSH. For that, first, we need to create an instance. In this article, I am
assuming that you already have a WordPress instance in Lightsail.
2:Install PUTTYgen
Download PUTTYgen through below mentioned link (For SSH), and install this file into
your system.
https://www.puttygen.com/
Now Open PUTTYgen and click on ‘load’ and select the downloaded SSH key file and after
that click on the ‘save private key’ file. Save this file with any name with this (*.ppk)
extension.
1/7
3:Install PUTTY
Download PUTTY through below mentioned link, and after that, install this file into your
system.
https://www.puttygen.com/
Now, Open PUTTY, in ‘Host Name’ input filed you need to write your Lightsail instance’s
Static IP address, now give the name to a session and then save and after that click on
‘Data’ under ‘Connection’ (left bar), write username of your instance in the field ‘Auto-
login username’ (bitnami, ubuntu, etc according to the type of instance ), again go to left
bar and click on ‘SSH'(click on SSH ‘+’ sign) then click on ‘Auth’, now choose Private
Key(*.ppk) file.
OR, If you want to open your AWS Lightsail Instance ‘ PHPMyAdmin ‘ database, and also
you want to check if your Instnace database is available in ‘PHPMyAdmin’ or not, then
follow these steps;
Go to the left bar and click on ‘SSH'(click on SSH ‘+’ sign) then click on ‘Tunnels’, now
add ‘8888’ in the Source post field and add ‘localhost:80’ in the Destination field. Now
click on ‘Session’ on the left bar and now choose your last session (in my case, the last
session was ‘aws session’ ) then click on ‘save’ and now click on ‘open’ then it will show
you a popup and you need to click on “Yes”.
2/7
4: Filezilla or WinSCP
Download Filezilla or WinSCP through this link, and after that, install this file into your
system.
https://filezilla-project.org/download.php
OR
https://winscp.net/eng/download.php
Open Filezilla/WinSCP to connect to your Instance. I’ll choose Filezilla for this work.
Go to the Edit option of Filezilla > open settings > click SFTP > pick the Private key of
your Lightsail Instance (*.ppk).
3/7
5:Filezilla Connection
After that go back to the main page of Filezilla and Write-host (IP/domain), the
username (server name), password (instance password), Port (22), and Quick
connect this.
After that, you will see your Lightsail instance directories are showing. Now, create a new
directory/folder for AWS Lightsail database backup and also copy the entire path with the
new folder.
sudo su
mysql -u root -p -h localhost (root mean USERNAME OF DB, P mean password)
show databases; (show all databases)
use DATABASE NAME; (Backup Database name)
show tables; (show all tables of your backup DB)
exit
Note: Must care for the Angle Bracket inside the Command. Don’t change this Angle
Bracket. Otherwise, you can’t take a backup of your AWS Lightsail database tables.
4/7
Commands:
After some time, you will see your database tables will have been created with your given
Filezilla path.
Now, you can delete all tables of your backup database from MySQL and after that, you
can also check your database backup whether it is imported in MySQL or not.
8:Check Database
Again back to the PUTTY, and write below mentioned commands
5/7
sudo su
mysql –u USERNAME –P
Enter Password
show databases;
use DBNAME; (backup database name )
show tables; (now you will see all tables are missing)
exit
Note: Must care for the Angle Bracket inside the Command. Don’t change this Angle
Bracket. Otherwise, you can’t import backups of your AWS Lightsail database tables.
Commands:
sudo su
mysql –u USERNAME –P
Enter Password
show databases;
6/7
use DBNAME; (backup database name)
show tables; (now you will see all tables are again showing)
exit
7/7