NOTE. operation system is ubuntu 14.*
I am breaking my head over my connection on my MYSQL server. I try to connect to my MYSQL server internal through my public ip. But i am unable to connect. While i am able to connect when i connect to localhost and when i connect externally.
# Instead of skip-networking the default is now to listen only on
# localhost which is more compatible and is not less secure.
#bind-address = 127.0.0.1
I commented the bind-adress out and this should bind the addres to 0.0.0.0. I also tried to setup the bind-adres to 0.0.0.0. This also doesnt work.
My hosts file is setup up as follows:
127.0.0.1 MY-IP
When i telnet on port 80 to my public ip there is no problem.
telnet MY-IP 80
I get:
Trying MY-IP...
Connected to MY-IP.
Escape character is '^]'.
But when i try this on port 3306 it keeps on:
Trying MY-IP...
I also granted all the right permissions to my MYSQL users. And i am possible to connect externaly and internaly. But it is not possible for me to connect internaly with my public ip.
Also i tried to find a solution with netstat.
netstat -tln
give mes
tcp 0 0 0.0.0.0:3306 0.0.0.0:* LISTEN
EDIT: Just disabled UFW. It still doesnt work.
ufw status
Status: inactive
EDIT2: Is it possible that mysql is ignoring the /etc/hosts file?
Could somebody help me a bit further with some great ideas where the problem might be.
You should change the bind address to 0.0.0.0 then restart the mysqld. Also make sure there is no firewall enabled:
iptables -n -L
if there are rules, blocking port 3306, delete them, or just disable the firwall with
iptables -F
also use netstat to check if the server is listening on the external ip:
netstat -tupan |grep :3306
Related
I am having problem to connect to MariaDB on Linuc GCP VM. I have followed all practices to expose the VM on 3306, I use ephemeral IP. The VM is reachable as I have nginx installed. I have create remote user in MySQL, enabled remote access but still nothing. When i cannoct from my PC with MySQL Workbench i get connection error. What can it be?
I have also followed this:
enter link description here
Update
this the output of netstat:
$> netstat -ant | grep 3306
tcp 0 0 0.0.0.0:3306 0.0.0.0:* LISTEN
Result of nmap is more intersting though:
PORT STATE SERVICE
22/tcp open ssh
80/tcp open http
443/tcp closed https
3389/tcp closed ms-wbt-server
I do not see 3306 but it is a port I have opened on firewall rule in GCP... How can it be is not shown?
Ok, I have found a mistake. It was in the GCP firewall configuration rule. The tag name of the VM was spelled wrongly. thanks.
I want to connect to MySQL(it's running on my local machine) using JDBC. I am able to connect to MySQL using Url:
"jdbc:mysql://localhost:3306"
When I tried
"jdbc:mysql://192.xxx.xxx.xxx:3306"
I got errors.
I am working on Ubuntu & my etc/hosts file has this entry:
127.0.0.1 localhost 192.xxx.xxx.xxx
Any pointer on this?
Edit:
my.cnf has this enrty:
bind-address = 127.0.0.1
netstat -na | grep 3306 gave me:
tcp 0 0 127.0.0.1:3306 0.0.0.0:* LISTEN
tcp 0 0 127.0.0.1:3306 127.0.0.1:57243 ESTABLISHED
As mentioned in comments: The BIND-ADDRESS setting in my.cnf forced mysql to listen an 127.0.0.1 only so no network connect from outside is possible.
Remove bind address and you'll be fine.
I think there is no need to bind the address so please remove bind address and get done. Note:- you need to restart mysql server.
I am trying to log into server using -
mysql -u abc -p abc -h 192.168.1.180
But getting error -
error 2003 : can't connect on '192.168.1.180' (10061)
Please help me out how to connect.
I am using window 7 and trying to connect win xp.
i am able to ping win 7 but win 7 not able to ping me(just for information).
10061 is 'network connection refused'.
Check if mysql is actually listening with:
netstat -an | find '3306'
That line, run on the host which has mysql running on it, will tell you if mysql has an open network port. If mysql is actually externally accessible, it should return one line something like this(pardon me, I run linux so from memory..):
TCP 0.0.0.0:3306 0.0.0.0:0 LISTENING
Translation..
mysql is listening on all adapters: 0.0.0.0
listening on port 3306 :3306
3306 is the default port.
I believe my.cnf has to have bind-address un-commented to enable network connections though.
Edit: so if it is listening, try getting to it from the other box without involving mysql yet:
telnet <mysqlboxip> 3306
if that fails, you have a firewall issue.
Edit: Barring a firewall issue, next guess is you have mis-configured one of your network adapters. Make sure the netmask is the same on both machines, and (without explaining networking) you don't change anything but the last number when changing the address.. For your average home network, netmask should most likely be 255.255.255.0, and ip address should be in the 192.168.(1 or 15).(2-254)
If in doubt, turn dhcp back on, and look at what your router gives you for an address/netmask with:
ipconfig -a
Most home routers reserve upper addresses for dhcp assigned, so pick a low one. Stay outside the range used by the router for dhcp basically.
To see where the machine thinks it should sending the traffic:
tracert <mysqlboxip>
An incorrect netmask or a faulty route on either box could cause the traffic destined for the other box to go out the public internet way or off into nothingness.
There shoudn't be space between -p and abc as abc is password
mysql -u abc -pabc -h 192.168.1.180
Also Check bind-address in my.cnf it should be commented and also check your firewall settings.
First you confirm this address is being ping by doing this
ping 192.168.1.180
MySQL remote access
I have a mysql database, running on Ubuntu Server 12.04 that I need to access remotely. For some reason this is become much more of a chore than I think it should be.
I have been through countless threads trying to resolve this issue with no luck what so ever. I do not have another linux box to test my connection. I am only using the MySQL Workbench from a Window 7 machine.
Here is what I have done so far:
set the iptables to accept
set the my.cnf to have the bind address of the server
created a user for both localhost and %
grant all to those users
restarted mysql
verified the user has all priv
verified mysql is listening on 3306
give the correct setting to Workbench and I get
"Your connection attempt failed for user 'USER' from your host to server at x.x.x.x:3306:
Can't connect to MySQL server on 'x.x.x.x' (10061)"
EDIT: I did notice that it show 'localhost and NOT the ipaddress when I run this cmd, but i'm not sure how to change that, or if it is even the issue. Thoughts?
# lsof -i -P | grep :3306
mysqld 5775 mysql 10u IPv4 154265 0t0 TCP localhost:3306 (LISTEN)
vim /etc/mysql/my.cnf
Change the following line to reflect as below:
(bind-address = 127.0.0.1)
bind-address = 0.0.0.0
Close the file then and restart mysql
To verify that mysql port 3306 is listening on all interfaces:
netstat -lnt | grep 3306
You should see this:
tcp 0 0 0.0.0.0:3306 0.0.0.0:* LISTEN
Find mysql config file (/etc/mysql/)
comment out the following line by putting a hash character in front of it as shown -> #bind-address = 127.0.0.1
-> Restart the server: sudo service mysql restart
For a test I set up user mysql user with % access. When I try to connect from a remote machine I get:
Enter password:
Then immediately get this:
ERROR 2003 (HY000): Can’t connect to MySQL server on ‘xxxxxxx’ (1)
Any ideas
Verify that you can connect to the mysql port with telnet from that remote machine, e.g.
telnet 192.168.1.52 3306
If that fails, there's a firewall somewhere preventing you to connect, or you're running mysql on a different port than the default(3306) or mysql isn't configured to listen on the interface/ip address (maybe it's just configured to listen on connections from localhost, check the bind-address configuration in the my.cnf config file)
Try to comment the bind-address = 127.0.0.1 in your /etc/mysql/my.cnf
# security:
# using "localhost" in connects uses sockets by default
# skip-networking
# bind-address = 127.0.0.1 --- commented
and watch the results. If not work try to use the IP address and if still not work. roll back the original file.
Can you telnet to the MySQL port 3306? If you can't then check to make sure the MySQL server service is listening on that port. Open a command prompt and type the following example.
Example: telnet yourmysqlservername.com 3306