I have a web app running on Lightsail instances stacked with LAMP (PHP 7/MariaDB 10 service). When I want to connect the instances to a Lightsail database instead of localhost, it works sporadically. The front end reads "cannot connect to MySQL database" and in the database server log I read : [MY-010055] [Server] IP address 'xxx.xxx.xxx.xxx' could not be resolved: Name or service not known" where the IP is the private IP address of my instance.
My instances and database are in the same region. Even though it is not necessary I have tried enabling VPC peering and opening the db to the public.
I can connect to the database using the command line tool: mysql -u uuuu -p -h hhhhh (ie: it is not a problem with entering the wrong credentials)
The web app seems to work with the dedicated Lightsail db server when I am the only one using it and until I open it to more traffic, then I get the connection error.
I have increased the number of max_connections from 65 to 500 using the aws CLI (localhost is 150). My current traffic is 2000 visitors per day.
aws lightsail update-relational-database-parameters --relational-database-name Database-1 --parameters "parameterName=max_connections,parameterValue=500,applyMethod=immediate"
Localhost is Mariadb 10, dedicated database server is MySQL 8
SSL is handled by Cloudflare. There's no SSL on my instance.
I don't want to keep using localhost dbs, I want to centralize my data in a dedicated database.
Does anyone know how to handle this problem?
Related
I have a mysql database runnnig on 127.0.0.1 on a VPS and now I need to connect to this database I saw that for this I must do a port forwarding in order to expose the mysql service to the internet otherwise I won't be able to connect, I saw here that I can do this connecting via SSH to the VPS and then run the command ssh -L 3306:127.0.0.1:3306 MY_SERVER_IP but I am not sure if this could unset or damage the VPS, this VPS is on production and the developers that created this left the project without finishing it so I have fear of doing a bad configuration and crash the productino server, which could be another way of do this? i.e be able to connect to the database Or is this the safer and correct way?
I have several vms instances running in my vm player. Several of them are cent-OS acting as HTTP servers. The HTTP server is/are accessible over network. The HTTP server is on nginx.
Then I have a vm running on cent-OS having MySQL installed. And another vm instance running MS Server 2019 having MySQL Installed. Am using MySQL 8.0.18 on both these machines.
All these machines are on same sub-net and gateway. for example the IP of one of my vm having HTTP server is 192.168.0.133. And the machines with cent-OS having MySQL Server installed is having IP 192.168.0.140 and machine with MS Server 2019 having MySQL server is having IP 192.168.0.141.
Now the issue is am unable to access any of these MySQL servers from the network(LAN) or in other words am unable to access the MySQL server running on either .140 or .141 from the machine .133 meanwhile am able to access the HTTP server across the network.
But if I running MySQL server on the same machine having HTTP server. There occurs no problem whether I use 127.0.0.1 or localhost in my db host configuration
My application is based on a PHP framework known as laravel.
I have disabled firewall from both the above machines. The port 3306 is open on both machines. Am able to ping all machines with each other.
I had tried things like:
skip-networking(commenting out this one or just deleting),
bind-address(IP of the machine running MYSQL server),
grant privileges on an ip or from any IP to users/user,
flush privileges
Even modified iptables.
Am entering db host as the IP of the machine where MySQL is running.
The error am getting is SQLSTATE[HY000] [2002] Connection refused
You've nearly done it all right. Setting bind-address to the server's IP however means that you must connect via SSH.
Change the IP to 0.0.0.0 and restart MySQL, and hopefully that should be you all set.
I have an Amazon Lightsail Ubuntu multi WordPress site set up with bitnami stack.
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.
I wonder if anybody else has managed to connect to an Instance's database, rather than a seperate database.
If this is not possible I wonder if there are any suggestions as how to best access this Instance's database remotely.
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
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
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
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.
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
Here is what you need to remotely connect MySQL on Lightsail.
https://lightsail.aws.amazon.com/ls/docs/en_us/articles/amazon-lightsail-connecting-to-your-mysql-database
There are 3 steps:
get the endpoint link
enable public mode
configure MySQL workbench
Yes I have - after a marathon tech support session with AWS :)
Although the Lightsail firewall may say port 3306 is open, the server instance itself may have its own firewall settings which close it. On my case teh AMI that was used to set up the instance was configured that way
I my case it was Ubuntu but here is the summary of the advice I got from AWS--
We have connected to the instance via SSH using the user-name 'xxxxxx' from terminal.
--
ssh -l xxxxx 34.xxx.xxx.221
Checked and confirmed that mysql is running on the instance.
systemctl status mysql
Confirmed the port on which mysql is running.
netstat -plnae | grep 'pid'
Checked the 'ufw' firewall rules and noticed that 3306 is not allowed.
ufw status
Opened the port 3306 on ufw firewall
ufw allow 3306
After performing these steps you were able to establish connection to your database
hth
Just upgraded my MySQL RDS instance from the free-tier db.t2.micro to an db.r3.large. Same storage, same security groups, same user groups/credentials, same VPC, same endpoint name, same everything.
I was previously able to access this same instance remotely through MySQL workbench before the upgrade, and according to AWS my endpoint location has not changed.
The error message received:
Can't connect to MySQL server on 'blahblah.rds.amazonaws.com' (10060)
I've tried restarting several times. Ensured by security group allowed inbound TCP access on port 3306 for both 0.0.0.0/0 and ::/0
What else could be wrong?
You probably need to restart the MySQL workbench, not reboot the RDS.
As I described here, the database handles have changed, but the code doesn't notice. So the MySQL workbench is using outdated handles that are being rejected.
I am trying to transfer an existing mysql database that is located on my VPS to AWS RDS.
I have RDS set up and I am able to connect to the server just fine by connecting to one of my ec2 instances through ssh and using this command:
mysql -uuser -p -hxx.xx.us-west-2.rds.amazonaws.com
However, when I try to connect from my VPS (through ssh) I receive an ERROR 2003, which I believe is permission denied.
It doesn't seem to matter how I set my security group. I set the inbound to allow port 3306 from my server ip and that did not work, I even tried allowing all traffic on all ports from anywhere on my inbound rules and I still am unable to connect. The outbound has always been completely open.
If anyone can see anything that I am missing I would really appreciate some help.
Thanks.
Make sure your RDS instance is set to public if you want to access it externally. If in fact it's not publicly accessible then you'll need to recreate your instance and import your data, or take a snapshot and rebuild your RDS instance from the snapshot.
You only have ONE chance to modify it and that is at instance creation.
If you do this then make sure you security group only allows from a specific IP address or if you're using MySQL workbench rather use a SSH tunnel using SSH keys via an EC2 instance.
Is user a user you created manually in your RDS, or is it the admin user that was created when you created the instance? If the former, then make sure you have granted access to that user from your remote VPS.
Also, from your VPS, make sure you can open a TCP connection to the database. Try:
$ nc -v -z xx.xx.us-west-2.rds.amazonaws.com 3306
If the connection succeeds here but you still can't connect with the mysql CLI, you have a problem with the username/password/database connection info.