When I tried to use navicat to connect mysql on AWS, it always reject the connection.
I'm sure my IP address is correct and the port is correct as I checked on EC2 for several times. Also the username and password are correct too because I can log in mysql on EC2.
I don't know what is wrong here. Any help would be really appreciated.
The first thing that will validate is that your instance of aws has active the port to which you want to connect in this case 3306 if it does not work with this you can connect by means of a SSH of the following way remembering that it has to have active the port 22:
Configure the ssh option
host: add the one that EC2 gives you e.g. ec2-127-0-0-1.compute-1.amazonaws.com.
Port: 22.
user: ubuntu or root (or the one indicated in your aws configuration).
Authentication Method: public key.
Private key: your .pem
In general:
Connection Name: whatever you want
Host: localhost or 127.0.0.1
Port: 3306
User: the database user
Pass: the database user.
I want to create my own database with my tables to practice some SQL. I cannot create a database unless i connect to a server. I have tried Microsoft SQL Server Management Studio and MySQL Workbench but both failed.
In Microsoft SQL Server Management Studio, I tried:
Server Type: Database Engine
Server Name: "DESKTOP-MUO9FQ2" and "." and "local"
Authentication: Windows Authentication
GRAYED OUT:
Username: DESKTOP-MUO9FQ2\15072
Password:
In MySQL Workbench:
Connection Name: localhost
Host Name: 127.0.0.1
Port: 3306 and 1433
Username: root
How can I connect to any server so I can create my own database and play around with my data using SQL?
I installed MySql which includes MySql CLI, and it works fine.
You just have to install MySql and you will have the CLI includes.
In the installation, you will have to define a root user and a user each with password.
Then run MySql CLI and you will have to enter the root password you choose, and then it's done.
Now you can can create databases ,tables and so on...
I'm having trouble connecting to my database through mysql workbench even though I can do it through a console. It doesn't seem like I'm even getting past ssh because this is my error
Here are my connection settings:
Connection Method: Standard TCP/IP over SSH
SSH Hostname: DropletIP:22
SSH Username: forge
SSH Key File: C:\Users\username\.ssh\id_rsa
MySQL Hostname: 127.0.0.1
MySQL Server Port: 3306
Username: forge
The workbench is version 8 and the mysql version on the droplet is version 8.
I've tried switch all kinds of stuff around like removing the port on the ssh hostname, trying the public ssh key instead of the private, and changing the mysql hostname to the DropletIP. None of these worked.
Not really sure why this is happening. I appreciate any help.
you should use the server IP address as your MySQL HOSTNAME
I'm finished with my project and I'm trying to deploy it to AWS. I have an ec2 instance as my webserver with the following configuration details:
NodeJS using port 5000
PM2 (keeping server alive at all times)
NGINX as web server reading from my build file
MySQL within ec2 instance as my database. (using port 3306)
My problem is I'm having trouble establishing a connection from my local machine to my AWS ec2 instance that has the MYSQL db inside of it. I opened up MYSQL workbench and I can connect to it just fine there but when I try and establish a connection string to the DB from node.js it gives me an error.
I was able to successfully connect to the DB within MYSQL workbench but how can I connect to it now from nodejs connection string?
What I already tried was the following:
1) In AWS security group opening up TCP Rule for all incoming traffic at port 5000
2) In AWS security group opening up MYSQL/Aurora Rule for all incoming traffic at port 3306
3) Granting all privileges on . to user and flushing and restarting mysql server.
Error it gives me in the console.
`{ Error: connect ECONNREFUSED 14.54.xxx.xx:3306
at Object._errnoException (util.js:1019:11)
at _exceptionWithHostPort (util.js:1041:20)
at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1175:14)
--------------------
code: 'ECONNREFUSED',
errno: 'ECONNREFUSED',
syscall: 'connect',
address: '14.54.xxx.xxx',
port: 3306,
fatal: true }`
Here is my code trying to establish the connection:
```var mysql = require("mysql");
// Local Works just fine
// var connection = mysql.createConnection({
// host: "localhost",
// user: "root",
// password: "xxx",
// database: "devdb",
// charset: "utf8mb4"
// });
// Production Connection to AWS MYSQL instance (stuck on)
var connection = mysql.createConnection({
host: "14.54.xxx.xxx",
port: "3306",
user: "jordan",
password: "xxx",
database: "productiondb"
charset: "utf8mb4"
});
// Test the db connection
connection.connect(function(err) {
if (err) {
console.log(err);
} else {
console.log("Connected!");
}
});
module.exports = connection;
```
I expect to be able to successfully connect to the db instance from my NodeJS
Make sure again, I think your security groups have something wrong, maybe your server listening internally so It's happening. Go your EC2 security group and select Inbound and add rules as type=mysql, proto=tcp, port range=3306, source=0.0.0.0/0,::/0 (allow all)
There are a couple of reasons due to which this might be happening -
Configure MySQL database
#start MySQL server sudo service mysqld start
#run configuration sudo mysql_secure_installation
In the prompt, follow the following steps:
Enter current password for the root account: press Enter key
Set root password? Y
New password: yourpassword
Re-enter new password: yourpassword
Remove anonymous users? Y
Disallow root login remotely? n
Remove test database and access to it? Y
Reload privilege tables now? Y
If you are using RDS then you will have to provide NAT access to the VPC which holds your database. For more info please refer here
Actually I think I just figured it out.
So the default mysql configuration file has the ip binded to 127.0.0.1. However, I changed the binding to my ec2 public ip and also changed the default "mysql" to "jordan" and I saved the configuration file, restarted the mysql service and it now works.
Thank you for the suggestions I'll write this down in my documentation to check for in the future.
I am trying to create connection to mysql using Navicat but I am getting this error.
I am using following settings
Host/Ip Address: localhost
Port: 3306
UserName: root
Password:
You can Whether it is right by checking user&password
Try changing localhost to 127.0.0.1
Actually,I think only you can sign in by Mysql client then the same in Navicat work.