I am trying to connect to a MySQL database on a client server. The problem I have is happens when our MySQL on our local machine is running. I get an error from my windows service trying to connect to the client my sqlç
An attempt was made to access a socket in a way forbidden by its access permissions
It seems our local my sql is using the 3306 port and blocks it. if I stop MySQL on our server and run the windows service it is fine. How can I get around this?
PasswordConnectionInfo connectionInfo = new PasswordConnectionInfo("########",####, "######", "#######");
connectionInfo.Timeout = TimeSpan.FromSeconds(500);
SshClient client = new SshClient(connectionInfo);
client.Connect();
ForwardedPortLocal portFwld = new ForwardedPortLocal("127.0.0.1",3306,"127.0.0.1", 3306); client.AddForwardedPort(portFwld);portFwld.Start();
// using Renci.sshNet
DBConnect connection = new DBConnect(portFwld);
You can just forward client 3306 port on your local 3307 port.
Then use 3307 to connect to mysql.
You can test it by using putty for example :
Putty example here
try this : var port = new ForwardedPortLocal("localhost", 3307, "your remote server", 3306);
Related
I can access the database if I run the app from my local machine without problems, but after deployment on shinyapps.io, I get an error ("The application failed to start."). I suppose that I need to change to host IP from localhost to something else, but the IP address of my database instance does not work either.
pool<- dbPool(
drv = RMySQL::MySQL(),
dbname = 'XXXXXX',
username = 'XXXXXX',
password = 'XXXXXX',
host = '127.0.0.1',
port = 3307
)
For the local connection, I use Cloud SQL Proxy.
Any ideas how the app could connect to the database from the Shiny Server?
How can I account for both the local machine's connection and the cloud-to-cloud connection in my code?
This question is similar but without Cloud hosting:
Error to connect to database (Mysql) when publising shiny app
To connect to your Cloud SQL instance using public ip, the IP address of your Shiny server where your app is deployed must configured as an authorized network
You may check this link on how to configure authorized networks and connect your Cloud SQL instance using public ip address.
Note: If you're going to deploy your application, you may need to modify the host IP and use your sql instance public ip address in your code.
I have deployed my app on RaspberryPi server which demands connection to remote MySql db. The properties looks like:
# LOCAL DATABASE
#spring.datasource.url = jdbc:mysql://localhost:3306/test3?autoReconnect=true&useSSL=false
#spring.datasource.username = root
#spring.datasource.password = admin
# REMOTE DATABASE
spring.datasource.url = jdbc:mysql://modraszka.sth.sth:8822/test3?autoReconnect=true&useSSL=false
spring.datasource.username = root
spring.datasource.password = password
spring.datasource.driver-class-name=com.mysql.jdbc.Driver
But while I try to run the app it throws that:
The remote DB is on the same server as app was deployed.
Seems your host mane is not valid one (modraszka.sth.sth).
Try to ping it.
If its working try to telnet using telnet modraszka.sth.sth 8822.
If telnet is not working try to telnet to telnet modraszka.sth.sth 22.
Then its not works for you we can assume you have to grant access to mysql port in the remote server.
Check if your remote database is open for the internet or as it's default, running only localy
grant remote access of MySQL database from any IP address
I am try to using MySQL Workbench but its showing error "Cannot connect to database".Neither it taking it localhost or my Endpoint of AWS RDS as DNS in host in workbench.
"I am using Xampp for mysql server running on port number 3306 "
Error :
Cannot connect to DataBase Server
Your connection attemp to failed for user 'root' from host to server at localhost:NULL;
can't open named pipe to host:pipe:MySQL (2)
Please:
1.Check that mysql is running on server localhost.
2.Check that mysql is running on port NULL (note 3306 is the default,but this can be changed)
3.Check the root has rights to connect to localhost from your address .
4.Make sure you are both providing a password if nedded and using the correct password for localhost connecting from the host address you are connecting from.
If you want to test the connection to MySql, Use Heidi (i recommend it). If it didn"t work, check if your DataBase server is running in port 3306 by taping:
netstat -atp tcp | grep -i "listen".
You can also change listenning port in /xampp/mysql/bin/my.ini:
my.ini:
Password = your_password
port = 3306 ---> 3307
socket = "/ xampp / mysql / mysql.sock"``
Looks like you have no port configured. Check your connection settings that you have a port set.
Every time I try to connect to my mySQL on mysql workbench, it gives me this error message saying:
Your connection attempted failed for user 'root' from your host to server at http:x.x.x.x:3306: Cannot open SSH Tunnel:Error connecting SSH tunnel:Error Connecting to SSH server Error 11004 get addrinfo failed
I think you could get solution here: http://quintagroup.com/services/support/tutorials/mysql-linux
or follow this steps:
Open putty and accept the certificate of the server
hostname should be localhost ( in order to use local socket and not http conection)
local port should be something like 33010 not 3306
local port is the conection back port used by the plink and has nothing to do with mysql ports
New to connecting to databases and have no clue to where to begin to troubleshoot -
I am currently using HeidiSQL to connect to an external Mysql Database Server hosted on the Amazon Web Service - EC2.
I am able to access the database using HeidiSQL with the settings:
MySQL (SSH tunnel)
Hostname/ip: 127.0.0.1
user: (user)
password: (pw)
port 3306
in SSH tunnel tab:
plink.exe location is set to putty.exe
sshhost + port: (my host ip) port 22
private key file: (is set)
local port: 3307
Using this configuration I AM able to log into my database.
My problem is when I am trying to do it using my own putty commands using the port forwarding:
In Putty:
I set SSH>tunnels - source port: 3307, destination (my host ip):3306
Local and Auto.
I connect using my passwords and hostip
Back to HeidiSQL, I put my settings to:
MYSL (TCP/IP)
hostname: localhost
user: (user)
password(pw)
port 3307
and try to connect. I get the following error:
SL ERROR (2013): Lost connection to MySQL server at 'reading initial communication packet', system error: 0
From what I have read, this means my ssh tunnel is working but something else is wrong. I am now at a loss on why this doesn't work. Am i not setting something else up properly? Firewalling myself? My ultimate goal is to hook up another application to communicate with the database using ODBC orJDBC using the same port forwarding idea. Are there logs to check somewhere?
You must set
AllowTcpForwarding yes
PermitTunnel yes
in /etc/ssh/sshd_config
It seem's like your're trying to do this:
http://realprogrammers.com/how_to/set_up_an_ssh_tunnel_with_putty.html
It should work. I assume the ssh server and mysql server are running on the remote machine.
In Putty: I set SSH>tunnels - source port: 3307, destination (my host ip):3306 Local and Auto. I connect using my passwords and hostip
It should be: set SSH>tunnels - source port: 3307, destination 127.0.0.1:3306 Local and Auto.
heidisql: MYSL (TCP/IP) hostname: localhost user: (user) password(pw) port 3307
Notice that if you have a MySQL service running on your local machine, on the port your trying to listen (3307 ) you'll get a 2013 error, even if the local service is down! In that case, use any arbitrary unused port.
Also, if the remote mysql server has the user table (mysql database) restricted to certain hosts this won't work. Unless you find out how the server recognize himself (computer name) and add him on the user table or simply you use the '%' wildcard.
Follow below steps it solved my issue while connecting to Live server:
Find your IP (Google - what is my ip).
Go to C-Panel of your Live Server.
Go to Remote MySQL in C-Panel.
Add IP address that you got from Step 1 and save it.
Now try to connect through Heidi SQL.
Please let me know if it helped.