WHMCS: How to create a new DB using a Hook [duplicate] - php

I am getting error:
"Lost connection to MySQL server at 'reading initial communication packet, system error: 0"
while I am going to connect my db.
If I am using localhost everything is working fine.
But when I am using my live IP address like below, it's getting error:
mysql_connect("202.131.xxx.106:xxxx", "xxxx", "xxxxx") or die(mysql_error());

Someone here suggests that it might be a firewall problem:
I have just had this problem and found it was my firewall. I use PCTools Firewall Plus and it wasn't allowing full access to MySQL. Once I changed that it was fine.
Could that be it?
Also, someone here suggests that it might be because the MySQL server is bound to the loop-back IP (127.0.0.1 / localhost) which effectively cuts you off from connecting from "outside".
If this is the case, you need to upload the script to the webserver (which is probably also running the MySQL server) and keep your server host as 'localhost'

Open mysql configuration file named my.cnf and try to find "bind-address", here replace the setting (127.0.0.1 OR localhost) with your live server ip (the ip you are using in mysql_connect function)
This will solve the problem definitely.

Allow remote connect to MySQL.
Edit file:
>sudo nano /etc/mysql/my.cnf
Comment line:
#bind-address = 127.0.0.1
Restart MySQL:
>sudo service mysql restart
Create user for remote connection.
>mysql -uroot -p
CREATE USER 'developer'#'localhost' IDENTIFIED BY 'dev_password';
CREATE USER 'developer'#'%' IDENTIFIED BY 'dev_password';
GRANT ALL ON *.* TO 'developer'#'localhost';
GRANT ALL ON *.* TO 'developer'#'%';
In my case I need to connect remotely from Windows to VirtualBox machine with Ubuntu. So I need to allow port 3306 in iptables:
>iptables -A INPUT -i eth0 -p tcp -m tcp --dport 3306 -j ACCEPT

Had this problem when setting up a new slave server. Found it was the slave server IP address was missing from the master server /etc/hosts.allow file. Added the IP address and it let me connect to the master server.
Note that I use hosts.allow and hosts.deny to control access.

I had this problem and it ended up being the prior sys admin changed the port MySQL was running on. MySQL Workbench was trying to connect to the default 3306 but the server was running on 20300.

The error means that it didn't receive a response from the port it expected to find the server on. The causes range from contacting the wrong machine (For one of a number of reasons) to the server not being on the expected port.
Check which port your server is bound to in /etc/mysql/my.cnf. Does that correspond to what is in your connect statement. If they match then try connecting with mysql from the server itself and from the command line of the machine where you are running the client. If it works form one place and not another then you may have a firewall / router configuration issue.

One more reason...
I ran into an Ubuntu server where everything was customized and could not connect because of that same error.
This setting was inside /etc/ssh/sshd_config
PermitTunnel no
After turning into
PermitTunnel yes
I was able to connect remotely to my MySQL DB

The problem on my case was MySQL being bind only to the lo on linux.
in order to solve the problem i have edited the my.cnf (found at /etc/mysql/my.cnf) removing the line bind-address=127.0.0.1
this allows mysql to bind to any network interface

I just set up mysql on a windows box. I got the OP's error when trying to connect with the Navicat MySql client on the same box. I had to specify 127.0.0.1 as the host, and that got it.
localhost, or the servers actual ip address both did not work.

This error occurred to me while trying to connect to the Google Cloud SQL using MySQL Workbench 6.3.
After a little research I found that my IP address has been changed by the internet provider and he was not allowed in the Cloud SQL.
I authorized it and went back to work.

I faced the same problem. I checked and tried to set AllowTcpForwarding Yes but it was missing in my sshd_config so no help.I didn't change sshd_config or my.cnf. Make sure the ssh hostname is NOT the same with the mysql hostname(use localhost).
In workbench, choose + to add new connection and set the following:
connection method: standard TCP/IP over SSH
SSH Hostname: 192.168.0.50:22 (replace remote SSH server IP and port(optional))
SSH Username: sshuser
You can set password or add at the prompt
MYSQL Hostname: localhost or 127.0.0.1
MYSQL Server port:3306
You can set password or add at the prompt
Test connection. It should be successful then hit OK.Viola!

I ran into this exact same error when connecting from MySQL workbench. Here's how I fixed it. My /etc/my.cnf configuration file had the bind-address value set to the server's IP address. This had to be done to setup replication. Anyway, I solved it by doing two things:
create a user that can be used to connect from the bind address in the my.cnf file
e.g.
CREATE USER 'username'#'bind-address' IDENTIFIED BY 'password';
GRANT ALL PRIVILEGES ON schemaname.* TO 'username'#'bind-address';
FLUSH PRIVILEGES;
change the MySQL hostname value in the connection details in MySQL workbench to match the bind-address

The problem for me was that DNS queries were blocked by the FW within the subnet. The solution was to disable DNS lookups within MySQL.

The problem was quite stupid for me.
I used to get the same issue on AWS EC2 Ubuntu machine (MariaDB is installed locally for the time being), so I tried to make SSH tunneling, and had the same issue. So I tried to ssh tunnel over terminal:
ssh -L13306:127.0.0.1:3306 root#ip.address -i my/private/key.pem
And it told me this:
Please login as the user "ubuntu" rather than the user "root".
I changed ssh user from root to ubuntu, just like my ssh config, and it connected just fine.
So check your SSH connecting user.
I oversaw this, so this too half an hour of my time, so I hope this will be useful for you.

For me the config file was found "/etc/mysql/mysql.conf.d/mysqld.cnf" commenting out bind address did the trick.
As we can see here:
Instead of skip-networking the default is now to listen only on
localhost which is more compatible and is not less secure.

I am trying to connect my db docker container on Ubuntu 18.04, same problem.
First check your device by run nmcli dev to check if device docker0 is connected.
If it is not connected, try to restart docker service:
sudo service docker restart

I tried make a telnet over remote server on port 3306.
The error message is clear
Host 'x.x.x.x' is blocked because of many connection errors; unblock with 'mysqladmin flush-hosts'Connection closed by foreign host.
As root at server mysqladmin flush-hosts worked at all!

I had the same error when using localhost. I restarted the MySQL service and it worked fine.

in my case, I had ALL: ALL in hosts.deny. Changing this to ALL: PARANOID solved my problem when connecting over ssh

Ran into this same issue, Bind Address back and forth to no avail. Solution for me was flushing privileges.
mysql> FLUSH PRIVILEGES;

Firewalld blocks the IP address. so to give access, use these commands:
firewall-cmd --permanent --zone=trusted --add-source=YOUR_IP/32
firewall-cmd --permanent --zone=trusted --add-port=3306/tcp
firewall-cmd --reload

For me setting bind-address = 0.0.0.0 in mysql/my.cnf worked. It basically listens to all addresses (but still one port) then.
And don't forget restart your server: systemctl restart mysql

I just had the same problem, but in my case I solved it with
service mysqld start

In my case it was the university wifi blocking port 3306. I was able to connect by using a mobile hotspot.
Change to a mobile hotspot or another network, and if it works there, then you know that original network is blocking port 3306. If you get the same error on more than 1 network, then you know it's specific to your machine.

I had port 3306 in Docker container but in Dockerfile it was 33060. I edited the port in Docker container to 33060
Must have been added to the Dockerfile
ENV MYSQL_ROOT_HOST 172.17.0.1

I have done below 3 steps then working for me.
bind-address = "YOUR MACHINE IP" in my.cnf file at /etc/my.cnf
Restart service by command : service mysql restart
GRANT ALL PRIVILEGES ON yourDB.* TO 'username'#'YOUR_APPLICATION_IP' IDENTIFIED BY 'YOUR_PASSWORD' WITH GRANT OPTION;

I had the same issue installing MySQL docker image then trying to connect from WSL2 MySQL client.
As it was stated in the accepted answer that it should be a firewall issue, in my case this error was caused due to not allowing docker for windows to communicate to private network.
I changed the settings on "Firewall & network protection", "allow an app through firewall", "change settings" (need administrator rights) and allowed "Docker desktop backend" to connect to private network.

I had the same error on my Mac with a local MySQL installation. The problem was that the number files that MySQL was opening was too high for MacOS.
To see if you have the same problem you can run this command and look for File Descriptor errors:
tail -200 /usr/local/var/mysql/$(whoami).err | grep "Warning"
I added this line to my.cnf file and the problem was fixed:
table_open_cache = 200

Had the same problem, what worked for me was:
Go to Windows Firewall where you allow applications.
mysql probably won't be in the list, so you need to add it, its path is typically C:/Program Files (x86)/MySQL/bin/mysql
Mark both private and public networks, apply.

When connecting to Mysql remotely, I got the error.
I had this warning in /var/log/mysqld.log:
[Warning] IP address 'X.X.X.X' could not be resolved: Temporary failure in name resolution
I just added this line to /etc/hosts file:
X.X.X.X some_name
Problem solved! Not using skip-name-resolve caused some errors in my local app when connecting to MySQL.

Related

Fatal error: Uncaught mysqli_sql_exception: No connection could be made because the target machine actively refused it [duplicate]

I know there are many people already asked this , but this people mostly forgot password of blocked by firewall which I have none of this situations .
I am developing with php , and I need to connect to remote database to let all my team work on it .
localhost was just going fine , but when I tried to switch it gave me this error
No connection could be made because the target machine actively
refused it.
and this is my code where I want to connect to .nf.biz database :
$db=mysqli_connect($host,$user,$password,$db_name,3306);
Your MySQL server is only accepting connections on *nix socket (/var/run/mysqld/mysqld.sock if you're running Ubuntu) or for localhost only.
You have to edit your my.cnf (on Ubuntu again is located in /etc/mysql/my.cnf) and change the following:
bind-address = 0.0.0.0
And comment out the following
#skip-networking
Finally restart MySQL.
Be careful with that, if your MySQL machine is accessible from public Internet will be accepting connections from everybody!
Even if this is not your case, I will add the answer here, because the message for this bug is the same.
There is a bug in MySQL server when you have some alias for localhost in c:\Windows\System32\Drivers\etc\hosts, MySQL server is unable to accept connection to localhost.
Remove the alias and MySQL Server will start to accept connections to localhost.
I do not have the #skip-networking option.
I resolved it by hashing out the bind address line (See 3rd line below).
# 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 solved just adding the port in bind-address like that: 127.0.0.1:3388
Well this might be late but for future visitors,
I found out back then that biz.nf refuses any connections to it's DB from outside source which means that only the web-apps hosted on biz.nf have the access to their DB other than that you will get rejected.
Go to services enable the service named after the root user (under the category "Log On As" -> Network Service)
I fixed this by setting the bind-address in my.cnf to the server's public IP address:
# Instead of skip-networking the default is now to listen only on
# localhost which is more compatible and is not less secure.
bind-address = SERVER_IP_ADDRESS
This error occurs when the database is not responding.
I resolve this error by following steps:
Press CTRL+R then type service.msc. A window opens.
Check for MYSQL56 OR MYSQL57, click on that.
NOW on the left bottom corner of the window. click on the expand.
Again window refresh then u can see the start service option.
click on that and the error resolve.
This works for me. hope your error is also resolved.
mail me: rkkp1023#gmail.com
Using Wamp (php7) on Windows 10...
It is currently working then it suddenly displayed that error. I restarted my laptop and the error is gone...
You have to start you service for the currently active mysql server, like mine was mysql80 so the following steps might help:
start> cmd>run as administrator> sc start mysql80
Your MySQL server is only accepting connections on *nix socket (/var/run/mysqld/mysqld.sock if you're running Ubuntu) or for localhost only.
You have to edit your my.cnf (on Ubuntu again is located in /etc/mysql/my.cnf) and change the following:
bind-address = 0.0.0.0
And comment out the following
#skip-networking
Finally restart MySQL.
Be careful with that, if your MySQL machine is accessible from public Internet will be accepting connections from everybody!
sudo -s
sudo gedit /etc/mysql/my.cnf
bind-address = 0.0.0.0
#skip-networking
save
sudo service mysql restart
Worked perfect!

#2002 - The server is not responding (or the local MySQL server's socket is not correctly configured)

I can't access to PHPMyAdmin. when i want to go there, i got this error:
#2002 - The server is not responding (or the local MySQL server's socket is not correctly configured)
I googled this error but it don't clear.
I try to know that which port is open by this code :
pgrep mysql
two ports are open when mysql is running.
I want to access to PHPMyAdmin in my localhost. I am using Ubuntu OS
In Ubuntu, by default mysql is not listening to TCP/IP connections. It just uses a local socket.
The current local socket is configured in /etc/mysql/my.cnf . If you open this file, you should find something similar to:
[client]
port = 3306
socket = /var/run/mysqld/mysqld.sock
What you should do is just to open PHPMyAdmin's config file (config.inc.php) and change the socket address. Maybe there's no local socket configuration on your PHPMyAdmin, or maybe it is different. This file should contain a line like (of course, adapt the address to what you found on my.cnf):
$cfg['Servers'][$i]['socket'] = '/var/run/mysqld/mysqld.sock';
Steps just to run the mysql server after crash.
** Worked on wamp server **
Check the {System name}.err file inside your mysql data directory.
From the log find out the databases causing issues
Cut them out from the data directory (keep in some safe places).
Start mysql service
go to C:\Windows\System32\drivers\etc edit host add 127.0.0.1 localhost
and restart server refrance check ans
This means that mysql server is not started.
This is very simply if you are using wamp left click the wampserver icon then mysql then services then install service after that restart wamp and the problem is solved

Mysql No connection could be made because the target machine actively refused it

I know there are many people already asked this , but this people mostly forgot password of blocked by firewall which I have none of this situations .
I am developing with php , and I need to connect to remote database to let all my team work on it .
localhost was just going fine , but when I tried to switch it gave me this error
No connection could be made because the target machine actively
refused it.
and this is my code where I want to connect to .nf.biz database :
$db=mysqli_connect($host,$user,$password,$db_name,3306);
Your MySQL server is only accepting connections on *nix socket (/var/run/mysqld/mysqld.sock if you're running Ubuntu) or for localhost only.
You have to edit your my.cnf (on Ubuntu again is located in /etc/mysql/my.cnf) and change the following:
bind-address = 0.0.0.0
And comment out the following
#skip-networking
Finally restart MySQL.
Be careful with that, if your MySQL machine is accessible from public Internet will be accepting connections from everybody!
Even if this is not your case, I will add the answer here, because the message for this bug is the same.
There is a bug in MySQL server when you have some alias for localhost in c:\Windows\System32\Drivers\etc\hosts, MySQL server is unable to accept connection to localhost.
Remove the alias and MySQL Server will start to accept connections to localhost.
I do not have the #skip-networking option.
I resolved it by hashing out the bind address line (See 3rd line below).
# 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 solved just adding the port in bind-address like that: 127.0.0.1:3388
Well this might be late but for future visitors,
I found out back then that biz.nf refuses any connections to it's DB from outside source which means that only the web-apps hosted on biz.nf have the access to their DB other than that you will get rejected.
Go to services enable the service named after the root user (under the category "Log On As" -> Network Service)
I fixed this by setting the bind-address in my.cnf to the server's public IP address:
# Instead of skip-networking the default is now to listen only on
# localhost which is more compatible and is not less secure.
bind-address = SERVER_IP_ADDRESS
This error occurs when the database is not responding.
I resolve this error by following steps:
Press CTRL+R then type service.msc. A window opens.
Check for MYSQL56 OR MYSQL57, click on that.
NOW on the left bottom corner of the window. click on the expand.
Again window refresh then u can see the start service option.
click on that and the error resolve.
This works for me. hope your error is also resolved.
mail me: rkkp1023#gmail.com
Using Wamp (php7) on Windows 10...
It is currently working then it suddenly displayed that error. I restarted my laptop and the error is gone...
You have to start you service for the currently active mysql server, like mine was mysql80 so the following steps might help:
start> cmd>run as administrator> sc start mysql80
Your MySQL server is only accepting connections on *nix socket (/var/run/mysqld/mysqld.sock if you're running Ubuntu) or for localhost only.
You have to edit your my.cnf (on Ubuntu again is located in /etc/mysql/my.cnf) and change the following:
bind-address = 0.0.0.0
And comment out the following
#skip-networking
Finally restart MySQL.
Be careful with that, if your MySQL machine is accessible from public Internet will be accepting connections from everybody!
sudo -s
sudo gedit /etc/mysql/my.cnf
bind-address = 0.0.0.0
#skip-networking
save
sudo service mysql restart
Worked perfect!

mysql_connect not working for a site

so I finished a site locally, and I have been trying to start to transfer it to an online server. And this is probably a really stupid question but I've spent the last hour trying to find the answer and I can't. So this is a line of PHP code being run on the server (with the username and password changed, but the hostname the same):
if(!mysql_connect("www.bluestreakaquatic.com","username","password"))
die(mysql_error());
It produces this error:
Can't connect to MySQL server on 'www.bluestreakaquatic.com' (10061)
Can anyone possibly give me any sort of advice?
Your hosting provider probably doesn't allow external mySQL connections for security reasons.
If mySQL runs on the same server as your site, try replacing the domain name with localhost.
If that doesn't work, you need to ask your hosting provider for the correct database server address.
I had recently experienced the same problem.
If you have full access to your server (root privileges required):
Step 1: edit my.cnf (usually located in /etc)
Find the following line: [mysqld] and make sure line skip-networking is commented (or remove line) and add following line:
bind-address=YOUR-SERVER-IP
For example, if your MySQL server IP is 66.166.170.28 then entire block should be look like as follows:
[mysqld]
user = mysql
pid-file = /var/run/mysqld/mysqld.pid
socket = /var/run/mysqld/mysqld.sock
port = 3306
basedir = /usr
datadir = /var/lib/mysql
tmpdir = /tmp
language = /usr/share/mysql/English
bind-address = 66.166.170.28
# skip-networking
.......
Where
bind-address : IP address to bind to.
skip-networking : Don’t listen for TCP/IP connections at all. All interaction with mysqld must be made via Unix sockets. This option is highly recommended for systems where only local requests are allowed. Since you need to allow remote connection this line should be removed from my.cnf or put it in comment state.
Step 2: Grant access to all hosts
Start the MySQL monitor with this command: mysql or /usr/local/mysql/bin/mysql. Your shell prompt should now look like this: mysql>. Run this command:
GRANT ALL PRIVILEGES ON *.* TO 'USERNAME'#'%' IDENTIFIED BY "PASSWORD";
Where:
USERNAME is the username that you use when connecting using your php script.
PASSWORD is the password you use when connecting.
You now must flush MySQL's privileges. Run this command:
FLUSH PRIVILEGES;
Run this command to exit MySQL:
exit;
Step 3: restart mysql deamon
/etc/init.d/mysqld restart
or
/etc/init.d/mysql restart
depending on what linux distro is your server currently running.
If you are on a shared hosting environment:
It is unlikely that any hosting provider will allow remote connections to mysql server because of security risks. But you may be lucky if your hosting server uses DirectAdmin control panel or cPanel. If so, follow these steps:
For DirectAdmin:
Goto MySQL Management. Select your database and click on it. You will find a section named Access Hosts. Add a new host: (%)
For cPanel:
Goto Remote MySQL under Databases section and add % instead of myhost.com:
Also see the reference: http://dev.mysql.com/doc/refman/5.5/en/can-not-connect-to-server.html
If you're unable to connect to a remote mysql server from the web server, but could connect to the remote mysql server from your localhost, the server may not have permissions granted for your username originating from that host.
GRANT ALL PRIVILEGES ON database.* TO username#serverhostname IDENTIFIED BY 'password'

Lost connection to MySQL server at 'reading initial communication packet', system error: 0

I am getting error:
"Lost connection to MySQL server at 'reading initial communication packet, system error: 0"
while I am going to connect my db.
If I am using localhost everything is working fine.
But when I am using my live IP address like below, it's getting error:
mysql_connect("202.131.xxx.106:xxxx", "xxxx", "xxxxx") or die(mysql_error());
Someone here suggests that it might be a firewall problem:
I have just had this problem and found it was my firewall. I use PCTools Firewall Plus and it wasn't allowing full access to MySQL. Once I changed that it was fine.
Could that be it?
Also, someone here suggests that it might be because the MySQL server is bound to the loop-back IP (127.0.0.1 / localhost) which effectively cuts you off from connecting from "outside".
If this is the case, you need to upload the script to the webserver (which is probably also running the MySQL server) and keep your server host as 'localhost'
Open mysql configuration file named my.cnf and try to find "bind-address", here replace the setting (127.0.0.1 OR localhost) with your live server ip (the ip you are using in mysql_connect function)
This will solve the problem definitely.
Allow remote connect to MySQL.
Edit file:
>sudo nano /etc/mysql/my.cnf
Comment line:
#bind-address = 127.0.0.1
Restart MySQL:
>sudo service mysql restart
Create user for remote connection.
>mysql -uroot -p
CREATE USER 'developer'#'localhost' IDENTIFIED BY 'dev_password';
CREATE USER 'developer'#'%' IDENTIFIED BY 'dev_password';
GRANT ALL ON *.* TO 'developer'#'localhost';
GRANT ALL ON *.* TO 'developer'#'%';
In my case I need to connect remotely from Windows to VirtualBox machine with Ubuntu. So I need to allow port 3306 in iptables:
>iptables -A INPUT -i eth0 -p tcp -m tcp --dport 3306 -j ACCEPT
Had this problem when setting up a new slave server. Found it was the slave server IP address was missing from the master server /etc/hosts.allow file. Added the IP address and it let me connect to the master server.
Note that I use hosts.allow and hosts.deny to control access.
I had this problem and it ended up being the prior sys admin changed the port MySQL was running on. MySQL Workbench was trying to connect to the default 3306 but the server was running on 20300.
The error means that it didn't receive a response from the port it expected to find the server on. The causes range from contacting the wrong machine (For one of a number of reasons) to the server not being on the expected port.
Check which port your server is bound to in /etc/mysql/my.cnf. Does that correspond to what is in your connect statement. If they match then try connecting with mysql from the server itself and from the command line of the machine where you are running the client. If it works form one place and not another then you may have a firewall / router configuration issue.
One more reason...
I ran into an Ubuntu server where everything was customized and could not connect because of that same error.
This setting was inside /etc/ssh/sshd_config
PermitTunnel no
After turning into
PermitTunnel yes
I was able to connect remotely to my MySQL DB
The problem on my case was MySQL being bind only to the lo on linux.
in order to solve the problem i have edited the my.cnf (found at /etc/mysql/my.cnf) removing the line bind-address=127.0.0.1
this allows mysql to bind to any network interface
I just set up mysql on a windows box. I got the OP's error when trying to connect with the Navicat MySql client on the same box. I had to specify 127.0.0.1 as the host, and that got it.
localhost, or the servers actual ip address both did not work.
This error occurred to me while trying to connect to the Google Cloud SQL using MySQL Workbench 6.3.
After a little research I found that my IP address has been changed by the internet provider and he was not allowed in the Cloud SQL.
I authorized it and went back to work.
I faced the same problem. I checked and tried to set AllowTcpForwarding Yes but it was missing in my sshd_config so no help.I didn't change sshd_config or my.cnf. Make sure the ssh hostname is NOT the same with the mysql hostname(use localhost).
In workbench, choose + to add new connection and set the following:
connection method: standard TCP/IP over SSH
SSH Hostname: 192.168.0.50:22 (replace remote SSH server IP and port(optional))
SSH Username: sshuser
You can set password or add at the prompt
MYSQL Hostname: localhost or 127.0.0.1
MYSQL Server port:3306
You can set password or add at the prompt
Test connection. It should be successful then hit OK.Viola!
I ran into this exact same error when connecting from MySQL workbench. Here's how I fixed it. My /etc/my.cnf configuration file had the bind-address value set to the server's IP address. This had to be done to setup replication. Anyway, I solved it by doing two things:
create a user that can be used to connect from the bind address in the my.cnf file
e.g.
CREATE USER 'username'#'bind-address' IDENTIFIED BY 'password';
GRANT ALL PRIVILEGES ON schemaname.* TO 'username'#'bind-address';
FLUSH PRIVILEGES;
change the MySQL hostname value in the connection details in MySQL workbench to match the bind-address
The problem for me was that DNS queries were blocked by the FW within the subnet. The solution was to disable DNS lookups within MySQL.
The problem was quite stupid for me.
I used to get the same issue on AWS EC2 Ubuntu machine (MariaDB is installed locally for the time being), so I tried to make SSH tunneling, and had the same issue. So I tried to ssh tunnel over terminal:
ssh -L13306:127.0.0.1:3306 root#ip.address -i my/private/key.pem
And it told me this:
Please login as the user "ubuntu" rather than the user "root".
I changed ssh user from root to ubuntu, just like my ssh config, and it connected just fine.
So check your SSH connecting user.
I oversaw this, so this too half an hour of my time, so I hope this will be useful for you.
For me the config file was found "/etc/mysql/mysql.conf.d/mysqld.cnf" commenting out bind address did the trick.
As we can see here:
Instead of skip-networking the default is now to listen only on
localhost which is more compatible and is not less secure.
I am trying to connect my db docker container on Ubuntu 18.04, same problem.
First check your device by run nmcli dev to check if device docker0 is connected.
If it is not connected, try to restart docker service:
sudo service docker restart
I tried make a telnet over remote server on port 3306.
The error message is clear
Host 'x.x.x.x' is blocked because of many connection errors; unblock with 'mysqladmin flush-hosts'Connection closed by foreign host.
As root at server mysqladmin flush-hosts worked at all!
I had the same error when using localhost. I restarted the MySQL service and it worked fine.
in my case, I had ALL: ALL in hosts.deny. Changing this to ALL: PARANOID solved my problem when connecting over ssh
Ran into this same issue, Bind Address back and forth to no avail. Solution for me was flushing privileges.
mysql> FLUSH PRIVILEGES;
Firewalld blocks the IP address. so to give access, use these commands:
firewall-cmd --permanent --zone=trusted --add-source=YOUR_IP/32
firewall-cmd --permanent --zone=trusted --add-port=3306/tcp
firewall-cmd --reload
For me setting bind-address = 0.0.0.0 in mysql/my.cnf worked. It basically listens to all addresses (but still one port) then.
And don't forget restart your server: systemctl restart mysql
I just had the same problem, but in my case I solved it with
service mysqld start
In my case it was the university wifi blocking port 3306. I was able to connect by using a mobile hotspot.
Change to a mobile hotspot or another network, and if it works there, then you know that original network is blocking port 3306. If you get the same error on more than 1 network, then you know it's specific to your machine.
I had port 3306 in Docker container but in Dockerfile it was 33060. I edited the port in Docker container to 33060
Must have been added to the Dockerfile
ENV MYSQL_ROOT_HOST 172.17.0.1
I have done below 3 steps then working for me.
bind-address = "YOUR MACHINE IP" in my.cnf file at /etc/my.cnf
Restart service by command : service mysql restart
GRANT ALL PRIVILEGES ON yourDB.* TO 'username'#'YOUR_APPLICATION_IP' IDENTIFIED BY 'YOUR_PASSWORD' WITH GRANT OPTION;
I had the same issue installing MySQL docker image then trying to connect from WSL2 MySQL client.
As it was stated in the accepted answer that it should be a firewall issue, in my case this error was caused due to not allowing docker for windows to communicate to private network.
I changed the settings on "Firewall & network protection", "allow an app through firewall", "change settings" (need administrator rights) and allowed "Docker desktop backend" to connect to private network.
I had the same error on my Mac with a local MySQL installation. The problem was that the number files that MySQL was opening was too high for MacOS.
To see if you have the same problem you can run this command and look for File Descriptor errors:
tail -200 /usr/local/var/mysql/$(whoami).err | grep "Warning"
I added this line to my.cnf file and the problem was fixed:
table_open_cache = 200
Had the same problem, what worked for me was:
Go to Windows Firewall where you allow applications.
mysql probably won't be in the list, so you need to add it, its path is typically C:/Program Files (x86)/MySQL/bin/mysql
Mark both private and public networks, apply.
When connecting to Mysql remotely, I got the error.
I had this warning in /var/log/mysqld.log:
[Warning] IP address 'X.X.X.X' could not be resolved: Temporary failure in name resolution
I just added this line to /etc/hosts file:
X.X.X.X some_name
Problem solved! Not using skip-name-resolve caused some errors in my local app when connecting to MySQL.

Categories