I'm setting up a new server on AWS Lightsail and all is good, but in my LEMP stack, I installed MySql and created my DB. For some reason though I cannot remote into that DB via my DB client (using TablePlus).
In the past using Vultr or Digital Ocean servers I had to add the IP address to the etc/mysql/mysql.conf.d/mysqld.cnf
file, like this:
# bind-address = 127.0.0.1
bind-address = 34.xxx.xxx.xxx
This would allow me to login with my DB username and pass that I created.
Does AWS Lightsail not allow for this? They have a Create DB Instance service that they want you to buy, but trying to stay cheap on this and only need the DB I built in my server.
Any help on how to connect remotely with a DB client would be extremely appreciative.
Using Ubuntu 18.04 LTS
So I figured it out. If anyone comes across this issue try the following.
AWS Lightsail gives you 2 IP's
In your
etc/mysql/mysql.conf.d/mysqld.cnf
file do the following:In AWS Lightsail Firewall Add
MySQL/Aurora | TCP | 3306
Run the following commands on server:
Connecting With DB Client:
That's it. All should work now.
As mentioned below, you do need to create a new MySql User. You can do so like this:
2.
3.
To get Database working remotely go to
/etc/mysql/mysql.conf/mysqld.cnf
and change the bind-address:service mysql restart
(Add to new .env if using Laravel)
If you need to get a list of your MySql User do this:
SELECT User FROM mysql.user;
Helpful to double check your new user is in the system.You need to tell Lightsail that the MySQL port should be available publicly. Documentation is here.
I haven't used Lightsail myself (I use full AWS), but see if you can whitelist only your specific IP using the either the Lightsail firewall, or using iptables on Linux.