I have a problem in connecting to my MySQL server running on an EC2 Ubuntu instance.
In the /etc/mysql/mysql.conf.d/mysqld.cnf,
I've set the port=3306
I've set thebind-address=0.0.0.0.
Commented skip-external-locking
netstat -an | grep 3306 returns
tcp 0 0 0.0.0.0:3306 0.0.0.0:* LISTEN
I allowed the connections using sudo ufw allow 3306
Still Iam getting the error as below. (I have added the db.apim.com to /etc/hosts )
ERROR 2003 (HY000): Can't connect to MySQL server on 'db.apim.com' (110)
Note : I followed everything in this blog
This is resolved by adding a suitable inbound traffic rule.
By adding Type : TCP and Source: 0.0.0.0/0 as a new inbound traffic rule this issue resolved [1].
Thanks #GobindDeepSingh for pointing this out.
[1] https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/authorizing-access-to-an-instance.html
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.
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
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.
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
I have installed normal mysql with apt-get and now I need to connect it with my lampp server, when is lampp booting it echo "Another MySQL deamon already running" (of course - thats right), but when I open phpmyadmin it gives me an message
2002 - The server is not responding (or the local MySQL server's socket is not correctly configured)
So how I could connect non-lampp mysql with lampp - I suppose that will be with a mysql socket, but I don't know how...
mysql listens for two seperiate types of connections, tcp and unix socket. You can view what your mysqld process listens to with the netstat command:
# netstat -npl | grep mysql
tcp 0 0 127.0.0.1:3306 0.0.0.0:* LISTEN 2059/mysqld
unix 2 [ ACC ] STREAM LISTENING 6221 2059/mysqld /var/lib/mysql/mysql.sock
Default port for tcp is 3306, and default socket is /var/lib/mysql/mysql.sock (at least it is on RHEL). Local connections (such as the mysql command) tend to use the socket, while remote connections (other servers) need to use the TCP socket.
If your server isn't listening on one, you may have to specify them in your mysqld configuration. These values are controlled in the /etc/my.cnf file:
[mysqld]
socket=/var/lib/mysql/mysql.sock
port=3306
Also, if your TCP socket is listening on localhost only (127.0.0.1) you can specify this in the my.cnf file:
bind_address=0.0.0.0
0.0.0.0 means listen on all local interfaces. If you want it to listen on a specific IP address, specify it.