Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Access Lightsail Instance's database with MySQL Workbench

I have an Amazon Lightsail Ubuntu multi WordPress site set up with bitnami stack.

enter image description here

I'm looking for a way to access the Instance's database on Amazon Lightsail with MySQL Workbench remotely.

Please note that I do not have a seperate Lightsail database, as I'm trying to do things as cheaply as possible at the moment. So the following guide is not applicable to me.

Connecting to your MySQL database in Amazon Lightsail

According the wp-config.php MySQL database is using localhost:3306

I have static IP address 3.230.xxx.xxx. I have taken the DB username and password from the wp_config.php file.

I've entered the details.

enter image description here

I wonder if anybody else has managed to connect to an Instance's database, rather than a seperate database.

enter image description here

If this is not possible I wonder if there are any suggestions as how to best access this Instance's database remotely.

like image 607
Hevski Avatar asked Sep 26 '19 16:09

Hevski


People also ask

How do I access my AWS Lightsail MySQL database?

Sign in to the Lightsail console. On the Lightsail home page, choose the Databases tab. Choose the name of the database that you want to connect to. On the Connect tab, under the Endpoint and port section, note the endpoint and port information.


1 Answers

Found the answer using a similar youtube video which is used to connect to phpMyAdmin.

https://www.youtube.com/watch?v=9VdcQLDmYII

Basically you need to use Putty SSH tunneling in order to connect to the MySQL instance

  • First I added a new connection in Putty, make sure port 22 is open on the LightSail firewall

enter image description here

  • Go to the Connection -> SSH -> Auth tab on the right hand side menu Enter your SSH key which is downloaded from the Lightsail dashboard, it will need to be converted in the standard recognised by putty

enter image description here

  • Go to Connections -> Data tab on the right hand side menu. Add a new forwarded port we are forwarding localhost:3306 on the server to a port on our machine 2222

enter image description here

  • Start the connection via Putty.
  • Now in MySQL WorkBench go to the connection to database windows. Enter the port 2222 I entered the DB user and Password from wp-config.php file and was able to successfully connect.

enter image description here

Also found a second method

Within the MySQL Workbench you can change the connection method to `Standard TCP/IP over SSH'. Gave the SSH key and the relevant details on connection was accepted

enter image description here

like image 156
Hevski Avatar answered Sep 23 '22 00:09

Hevski