Lost Connection to Mysql Server at 'reading Initial Communication Packet' System Error 0
651 votes
30 answers
php - Lost connection to MySQL server at 'reading initial communication package', organization mistake: 0
I am getting error:
"Lost connection to MySQL server at 'reading initial communication parcel, system error: 0"
while I am going to connect my db.
If I am using localhost everything is working fine. Only when I am using my live IP address like below, it's getting error:
mysql_connect("202.131.thirty.106:xxxx", "xxxx", "xxxxx") or dice(mysql_error());
Undefined asked
397
votes
Answer
Solution:
Someone hither suggests that information technology might exist a firewall problem:
I accept just had this problem and establish 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. Promise that helps.
Could that be information technology?
Also, someone here suggests that it might exist because the MySQL server is bound to the loop-dorsum IP (127.0.0.ane / 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 likewise running the MySQL server) and keep your server host as 'localhost'
Undefined answered
Link to reply
590
votes
Answer
Solution:
Open mysql configuration file named my.cnf and attempt to find "demark-address", here replace the setting (127.0.0.1 OR localhost) with your live server ip (the ip you lot are using in mysql_connect function)
This will solve the problem definitely.
Thanks
Undefined answered
Link to answer
132
votes
Answer
Solution:
1) Permit remote connect to MySQL. Edit file:
>sudo nano /etc/mysql/my.cnf Comment line:
#bind-accost = 127.0.0.1 Restart MySQL:
>sudo service mysql restart ii) Create user for remote connectedness.
>mysql -uroot -p CREATE USER 'developer'@'localhost' IDENTIFIED Past 'dev_password'; CREATE USER 'developer'@'%' IDENTIFIED By 'dev_password'; GRANT ALL ON *.* TO 'developer'@'localhost'; GRANT ALL ON *.* TO 'programmer'@'%'; 3) In my case I need to connect remotely from Windows to VirtualBox machine with Ubuntu. And then I need to allow port 3306 in iptables:
>iptables -A INPUT -i eth0 -p tcp -one thousand tcp --dport 3306 -j Have
Undefined answered
Link to answer
611
votes
Answer
Solution:
Had this trouble when setting upward 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 information technology allow me connect to the master server.
Note that I utilisehosts.allow andhosts.deny to control admission.
Undefined answered
Link to answer
902
votes
Answer
Solution:
I had this trouble and information technology concluded up being the prior sys admin changed the port MySQL was running on. MySQL Workbench was trying to connect to the default 3306 only the server was running on 20300.
Undefined answered
Link to answer
28
votes
Answer
Solution:
The error means that information technology 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 beingness on the expected port.
Check which port your server is spring to in /etc/mysql/my.cnf. Does that correspond to what is in your connect statement. If they match so try connecting with mysql from the server itself and from the command line of the car where you are running the customer. If it works form ane identify and not another so you lot may have a firewall / router configuration upshot.
Undefined answered
Link to answer
321
votes
Answer
Solution:
The problem on my instance was MySQL existence bind only to the lo on linux. in society to solve the problem i have edited the my.cnf (constitute at /etc/mysql/my.cnf) removing the line bind-address=127.0.0.1
this allows mysql to bind to any network interface
Undefined answered
Link to answer
360
votes
Answer
Solution:
This error occurred to me while trying to connect to the Google Cloud SQL using MySQL Workbench half dozen.iii.
Afterwards a trivial research I institute that my IP address has been changed by the net provider and he was not allowed in the Cloud SQL.
I authorized it and went back to work.
Undefined answered
Link to answer
187
votes
Respond
Solution:
One more reason...
I ran into an Ubuntu server where everything was customized and could non connect because of that same error.
This setting was inside/etc/ssh/sshd_config
PermitTunnel no After turning into
PermitTunnel yeah I was able to connect remotely to my MySQL DB
Undefined answered
Link to answer
964
votes
Respond
Solution:
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 aforementioned box. I had to specify 127.0.0.1 every bit the host, and that got it.
localhost, or the servers actual ip address both did not work.
Undefined answered
Link to answer
949
votes
Answer
Solution:
I ran into this exact same error when connecting from MySQL workbench. Hither'southward how I fixed information technology. My /etc/my.cnf configuration file had the demark-address value prepare to the server's IP address. This had to be done to setup replication. Anyhow, I solved it past doing two things:
- create a user that tin can be used to connect from the bind accost 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 demark-address
Undefined answered
Link to answer
961
votes
Answer
Solution:
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.
Undefined answered
Link to answer
304
votes
Answer
Solution:
For me the config file was found "/etc/mysql/mysql.conf.d/mysqld.cnf" commenting out bind address did the pull a fast one on.
As we can see here: Instead of skip-networking the default is now to listen only on localhost which is more compatible and is non less secure.
Undefined answered
Link to answer
38
votes
Answer
Solution:
I tried brand atelnet over remote server on port3306. The error message is articulate
Host 'ten.x.x.x' is blocked because of many connexion errors; unblock with 'mysqladmin flush-hosts'Connectedness airtight by foreign host.
Asroot at servermysqladmin affluent-hosts worked at all!
Undefined answered
Link to answer
165
votes
Answer
Solution:
in my example, I had ALL: ALL in hosts.deny. Changing this to ALL: PARANOID solved my problem when connecting over ssh
Undefined answered
Link to answer
664
votes
Answer
Solution:
The problem was quite stupid for me.
I used to get the aforementioned upshot on AWS EC2 Ubuntu machine (MariaDB is installed locally for the time being), so I tried to make SSH tunneling, and had the aforementioned issue. So I tried to ssh tunnel over concluding:
ssh -L13306:127.0.0.1:3306 [email protected] -i my/individual/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, but like my ssh config, and information technology continued just fine.
And so check your SSH connecting user.
I oversaw this, so this likewise half an hour of my time, so I promise this will exist useful for you.
Undefined answered
Link to answer
971
votes
Respond
Solution:
Ran into this same issue, Demark Accost dorsum and along to no avail. Solution for me was flushing privileges.
mysql> Affluent PRIVILEGES;
Undefined answered
Link to answer
751
votes
Respond
Solution:
I faced the same problem. I checked and tried to set AllowTcpForwarding Aye but it was missing in my sshd_config so no assistance.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 fix the following:
- connection method: standard TCP/IP over SSH
- SSH Hostname: 192.168.0.50:22 (supplant remote SSH server IP and port(optional))
- SSH Username: sshuser
- You can set countersign 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 and then hitting OK.Viola!
Undefined answered
Link to respond
775
votes
Answer
Solution:
I am trying to connect my db docker container on Ubuntu 18.04, same trouble.
First check your device by runnmcli dev to check if devicedocker0 is continued.
If it is not connected, try to restart docker service:
sudo service docker restart
Undefined answered
Link to answer
615
votes
Answer
Solution:
Firewalld blocks the IP accost. 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
Undefined answered
Link to respond
959
votes
Answer
Solution:
I had the same fault when usinglocalhost. I restarted the MySQL service and it worked fine.
Undefined answered
Link to respond
455
votes
Answer
Solution:
For me settingbind-address = 0.0.0.0 inmysql/my.cnf worked. It basically listens to all addresses (merely still one port) and so.
And don't forget restart your server:systemctl restart mysql
Undefined answered
Link to reply
48
votes
Answer
Solution:
I but had the same problem, but in my case I solved information technology with
service mysqld showtime
Undefined answered
Link to answer
722
votes
Answer
Solution:
In my case it was the academy wifi blocking port 3306. I was able to connect by using a mobile hotspot.
Alter to a mobile hotspot or another network, and if it works there, then yous know that original network is blocking port 3306. If yous get the same error on more than i network, and then yous know it's specific to your car.
Undefined answered
Link to answer
108
votes
Answer
Solution:
I had the aforementioned issue installing MySQL docker image so trying to connect from WSL2 MySQL client.
As it was stated in the accepted answer that it should be a firewall upshot, in my case this error was caused due to non assuasive 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 individual network.
Undefined answered
Link to answer
365
votes
Answer
Solution:
I had the same mistake 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 y'all tin run this control and look forFile Descriptor errors:
tail -200 /usr/local/var/mysql/$(whoami).err | grep "Warning" I added this line to my.cnf file and the problem was stock-still:
table_open_cache = 200
Undefined answered
Link to answer
98
votes
Respond
Solution:
When connecting to Mysql remotely, I got the error. I had this alert in/var/log/mysqld.log:
[Warning] IP address 'X.X.X.Ten' could non be resolved: Temporary failure in name resolution I just added this line to/etc/hosts file:
Ten.X.10.X some_name Problem solved! Non usingskip-name-resolve caused some errors in my local app when connecting to MySQL.
Undefined answered
Link to answer
572
votes
Answer
Solution:
I had identical problem. To fix it I only changed host from localhost:3306 to simply localhost. And then error may acour when You sepcify unproper port for connection. It's better to leave it default.
Undefined answered
Link to answer
867
votes
Answer
Solution:
Database directory read-write permission also a problem i found. Just make sure your application is able to rw files on db location. Effort chmod 777 for testing.
Undefined answered
Link to reply
306
votes
Answer
Solution:
If bind-address is non present in your configuration file and mysql is hosted on AWS instance, delight check your security group. In ideal conditions, the inbound rules should have all connection from port 3306 and outbound rule should respond dorsum to all valid IPs.
Undefined answered
Link to answer
Source
Share
Didn't find the answer?
Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for complimentary.
Like questions
Find the reply in similar questions on our website.
sherrillnamen1985.blogspot.com
Source: https://programmierfrage.com/items/whmcs-how-to-create-a-new-db-using-a-hook
Postar um comentário for "Lost Connection to Mysql Server at 'reading Initial Communication Packet' System Error 0"