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
Related
I have a mysql db running on a remote server. I am trying to use it in a tomcat webapp. My username to log in is still root#localhost, but would the jdbc connection string still be: jdbc:mysql://localhost:3306/FlashCardShark? Or would it be at my IP address. I confirmed that the port is 3306 with show varialbes
Not at all, if your tomcat on machine A, and mysql on B, then you must have to specifiy the URL to jdbc:mysql://B-ip:3306/dbname.
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);
I have a MySQLdb running on my Ubuntu Laptop. I have created a database.
I need to access this database on my laptop from my Raspberry pi.
I have installed PyMySQL on my raspberry pi. I have also configured the mysqld.conf file in my laptop and commented out the bind address line.
But eherytime i use the following command on my RPi
conn = pymysql.connect(host='192.168.10.7', port='3306', user='root', passwd='password', db='temps')
192.168.10.7 is my laptop ip address. This IP address can be pinged from my RPi.
but i get error
pymysql.err.InternalError: (1130, "Host '192.168.10.7' is not allowed to connect to this MSQL server")
Do I need to make anymore changes in the configuration? If yes, can you please guide me?
By default MySQL Server on Ubuntu run on the local interface, This means remote access to the MySQL Server is not Allowed. To enable remote connections to the MySQL Server you need to change value of the bind-address in the MySQL Configuration File.
Open the /etc/mysql/mysql.conf.d/mysqld.cnf file (/etc/mysql/my.cnf in Ubuntu 14.04 and earlier versions).
Under the [mysqld] Locate the Line,
bind-address = 127.0.0.1
And change it to,
bind-address = 0.0.0.0
Then, Restart the Ubuntu MysQL Server.
systemctl restart mysql.service
Now Ubuntu Server will allow remote access to the MySQL Server, But still you need to configure MySQL users to allow access from any host.
For example, when you create a MySQL user, you should allow access from any host.
CREATE USER 'username'#'%' IDENTIFIED BY 'password';
I'm trying to connect to a remote DB with MySQL Workbench over SSH. The remote DB I'm trying to connect to has firewall which is private key protected (I have coverted this to OPEN SHH). I keep getting an error when I try to connect, I'm just a little confused on what is the information of the DB I should be using. I consistently see people use localhost and the DB changed intermittadely at the same point in different questions. My set up is currently that I have to connect to the server of the firewall(check) now there are multiple VMs running I wish to connect to e.g. 192.1.91.0. I have also a port set up to this on putty( I don't know if this is relevant) on localhost 5000. When I try to connect using 192.1.91.0 port 3306 or localhost 5000. I get the same error. Can anyone help. Attached is an image of the information I put into workbench
I think there are a few misunderstandings here. A firewall is not protected by a keypair. An SSH connection is. The firewall only filters network traffic using specific rules (e.g. only let it pass for enabled network ports). When you use an SSH connection you have to use the MySQL address as seen from the remote SSH connection end. That means if the MySQL server runs on the same machine as the SSH server (which is what you connect to when you use an SSH tunnel) then the address is localhost (or the IPv4/IPv6 loopback address). See my video about connection creation and troubleshooting on Youtube for more details.
To connect workbench with a private database you will need a 'jump host' also called 'bastion host' which can be any EC2 instance in a public subne in same VPC as database.
Follow Below Steps:
Open the security group attached to the database, and add new rule as below:-
Type:MYSQL/Aurora, Protocol:TCP, PortRange:3306,
Source:securitygroupofEC2 (you can all security group by entering
'sg-')
Open the security group attached to the EC2, and make port 22 is open. If not, add a new rule as below:-
Type:SSH, Protocol:TCP, PortRange:22, Source:MY IP
Open Workbench, Click New connection
- Standard TCP/IP over SSH
- SSH Hostname : < your EC2 Public IP > #34.3.3.1
- SSH Username : < your username > #common ones are : ubuntu, ec2-user, admin
- SSH KeyFile: < attach your EC2 .pem file>
- MYSQL Hostname: <database endpoint name> #mydb.tbgvsblc6.eu-west-1.rds.amazonaws.com
- MYSQL Port: 3306
- Username : <database username>
- Password: <database password>
Click 'test connection' and boom done!!
If the MySQL Server is configured to accept remote connections, you can use the servers IP address, but then you don't need to connect over ssh. Once you choose connect over ssh, the workbench creates a portforwarding using the ssh credentials to the specified server. So you have to use localhost as MySQL hostname. Due to the portforwarding, the request will be forwarded to your remote machine. In short: As far as I understand your question, you have to use localhost.
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