MariaDB is installed on server with IP 1.2.3.4, new MySQL user has been created on 1.2.3.4 for remote IP a.b.c.d, but while trying to connect MySQL on 1.2.3.4 from a.b.c.d giving error:
ERROR 2003 (HY000): Can't connect to MySQL server on '1.2.3.4' (111
"Connection refused")
Investigation-:
trying to telnet from a.b.c.d to 1.2.3.4 at port 3306 also not working
surprisingly when trying to connect mysql from 1.2.3.4 directly using server IP 1.2.3.4 is also throwing error "ERROR 2003 (HY000): Can't connect to MySQL server on '1.2.3.4' (111)
While trying to connect mysql using mysql -h localhost -u root -p is successfully working.
What we are looking for, we want to connect mysql from a.b.c.d to 1.2.3.4, please suggest what we are missing.
addtional information:
on server 1.2.3.4 /etc/mysql/my.cnf is not present, there exist '/etc/my.cnf'
trying to find solution we are referring link "webdock.io/en/docs/how-guides/database-guides/…" some edit is mentioned to in file "/etc/mysql/my.cnf" which is not present.
Added from comment below
Firewall has been disabled, user has already created, mariadb.log showing error while binding
221215 17:10:12 [ERROR] Can't start server: Bind on TCP/IP port. Got error: 99: Cannot assign requested address
221215 17:10:12 [ERROR] Do you already have another mysqld server running on port: 3306 ?
221215 17:10:12 [ERROR] Aborting
Some points to consider.
Check firewall (port 3306 should be allowed for the remote ip if you are running MariaDB on 3306 port )
The user should exists (which you have) and it should be something like;
user#your_remote_ip
Check bind-address in the configuration file, if it set to 127.0.0.1 it will allow only localhost login.
It is a good idea to check the logs , usually located on /var/log/mysql/ or you could verify from the configuration file where the logs are located
log_error = /var/log/mysql/error.log
Most probably it might be a firewall issue.
Make sure that the port on which the database server is running is not closed and is exposed publicly.
Also check if the database configurations allow binding IP is not only set to 127.0.0.1 but every IP can bind.
Related
I have installed MySQL 8.0.25 on Ubuntu 20.04 LTS (ARM) instance on AWS.
I can access it using 127.0.0.1 address locally, but can't access it remotely from another instance.
"Bind-address" was commented out originally, I uncommented it and changed to "0.0.0.0" (mysql service was restarted) - didn't help, so I commented it back.
"Skip-networking" is not in the cnf file.
I changed the port to 3307 just to be sure that I'm looking at the right cnf, and now MYSQL does listen to port 3307:
locally I can connect using port 3307, but not remotely:
Here are the iptables:
I know that firewall works well, because if I remove port 3307 from the rules, the error is different:
As you can see, TCP error 111 ("Connection Refused") became error 113 ("No Route to Host").
Telnet connection is refused with the same error:
I've rebooted the MySQL instance - no change.
Why would MYSQL refuse remote connection, if "bind-address" is commented out, and firewall is open?
#stdunbar's comment pointed me in the right direction.
The problem happened because I followed the MYSQL installation instructions at https://www.digitalocean.com/community/tutorials/how-to-install-mysql-on-ubuntu-20-04 , and ran the security script while configuring MYSQL:
sudo mysql_secure_installation
For some reason, this script causes MYSQL to ignore the bind-address setting in the cnf file, while it still uses the port setting - very confusing!
When I installed MYSQL without running the security script, the "local address" of the MYSQL daemon in the netstat -lnp | grep mysql command changed from 127.0.0.1:
to 0:0:0:0 :
After this, MYSQL started to accept remote connections.
Of course, I still had to create a remote user:
CREATE USER 'root'#'remotehostname' IDENTIFIED WITH caching_sha2_password BY 'newpassword';
GRANT ALL PRIVILEGES ON *.* TO 'root'#'remotehostname' WITH GRANT OPTION;
I am using PyCharm to connect to my local MySQL database running at localhost port 3306. Here's my JDBC url in the "Data Sources and Drivers" window as shown by PyCharm:
jdbc:mysql://localhost:3306/mydb
When I try to connect or click "Test Connection" I am getting this error in IntelliJ:
Error: Connection to MySQL failed.
Connection to Local MySQL failed.
[08S01] Communications link failure.
The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.
I can connect to mysql using the command-line client just fine, it's just PyCharm that's not working. What am I doing wrong?
Make sure your MySQL isn't listening on IPv6 address. For some reason IntelliJ/PyCharm has problems when connecting to MySQL running on IPv6 address.
To see what address your MySQL server is listening on, type:
$ ss -ntl|grep 3306
LISTEN 0 80 [::1]:3306 [::]:*
The [::1]:3306 part means it's listening on IPv6 address on localhost.
To change to IPv4, open /etc/mysql/my.cnf and add/set the bind-address parameter in [mysqld] section to 127.0.0.1 instead of localhost:
...
[mysqld]
...
port = 3306
bind-address = 127.0.0.1
...
Then restart mysqld.service and you'll be able to connect via IntelliJ/PyCharm.
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.
I am trying to remotely connect to a MySQL server. I have followed advice from (1) and setup a user on the ip address I will be remotely accessing from.
user$ mysql -u TestUser -p -h 129.169.66.149
Enter password:
ERROR 2003 (HY000): Can't connect to MySQL server on '129.169.66.149' (60)
I have checked and the port (default, 3306) is correct and the ip address is correct. MySQL is also running.
From a remote computer, I can successfully ping the server
ping 129.169.66.149
64 bytes from 129.169.66.149: icmp_seq=48 ttl=63 time=1.010 ms
But when I use Telnet:
TELNET 129.169.66.149
Trying 129.169.66.149...
telnet: connect to address 129.169.66.149: Operation timed out
telnet: Unable to connect to remote host
Can anyone advise? Is this a firewall issue?
(1) - https://superuser.com/questions/826896/access-wordpress-mysql-database-remotely
First try to check TCP connection issue, using netcat and telnet : on the mysql server, stop mysqld (to release port 3306) and run netcat on listen mode :
nc -l -p 3306
Now, netcat is listening port 3306 (like mysqld does when it's running) and will show what happen on that port (incoming connections, what's in the wire...).
On your remote computer (mysql client), try to connect to the mysql server host :
telnet 129.169.66.149 3306
or :
nc 129.169.66.149 3306
If this is not working, this is not a mysql server configuration issue but a network issue, and you must check your router firewall rules.
Otherwise, your problem comes from mysql server settings. Check your mysql configuration file for bind-address, and remove them to make mysqld accept clients from any IP address.
The 3306 port on the 129.169.66.149 server is closed you'll have to open this port
Use this reference as a guide http://www.cyberciti.biz/faq/linux-unix-open-ports/
When I attempt to connect from Windows 7 using 32bit and 64bit mysql-connector-odbc-5.3.2 and the connectionstring:
Provider=MSDASQL;Driver={MySQL ODBC 5.3 Driver};Server=192.168.1.13;Port=3306;Database=mydb;Uid=root;Pwd=****;
I get
[Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified
Likewise with version 5.2.6. After downgrading the provider to 5.1 I get:
[MySQL][ODBC 5.1 Driver]Can't connect to MySQL server on '192.168.1.13' (10060)
which is more encouraging as it has at least recognised the provider.
I have tried adding a firewall rule to allow outbound connections to port 3306. I've tried disabling my local firewall. I have checked that the server is listening on port 3306 and verified the IP address. (tcp 0 0 127.0.0.1:3306 0.0.0.0:* LISTEN) I have further verified that I can access the server and that MySQL is running.
When I attempted to connect using the IP address from an ssh terminal to the server itself:
mysql -u root -h 192.168.1.13 -D whiskeywheel -p
I am prompted for the password after which I get:
ERROR 2003 (HY000): Can't connect to MySQL server on '192.168.1.13' (111)
I have added the host/user to the user table in the mysql database and restarted MySQL. I've granted 'ALL' on the database to the user at anyhost ('%') and I've explicitly added access to port 3306 to the ubuntu firewall:
iptables -A INPUT -p tcp --dport 3306 -j ACCEPT
I will of course restrict access prior to deployment but I need to be able to interact with the database in a meaningful form while I'm developing it. I'm happy to re install any of the various components and start again as this is early enough in the project but ideally I'd like to know what I've misconfigured or where I went wrong.
mysql server by default only bind to the loopback address on the sever (127.0.0.1). you have to edit the my.cnf file of the server and do a restart of the mysql server.
also note that specifying localhost is treated special by mysql server. it does not call 127.0.0.1 as one would expects.
more info here on how to bind to your external ipaddress:
http://www.cyberciti.biz/faq/unix-linux-mysqld-server-bind-to-more-than-one-ip-address/