• Register
0 votes
146 views

Problem :

I am new to MySQL and facing following error message while trying to connect my DB:

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

If I am trying to connect my MySQL DB to the localhost then everything is working as it should. But when I am trying to connect my MySQL DB with my live IP address like following one, it is giving me the above mentioned error:

mysql_connect("202.131.xxx.106:xxxx", "xxxx", "xxxxx") or die(mysql_error());

Does anyone ever faced such issue? Also please let me know the solution for this issue if possible.

6 5 3
6,930 points

Please log in or register to answer this question.

1 Answer

0 votes

Solution :

I had faced the same issue in the recent past and I resolved my issue by following below mentioned simple steps:

1) Allow the remote connecion to MySQL.Edit file:

>sudo nano /etc/mysql/my.cnf

Comment below line:

#bind-address       = 127.0.0.1

Restart the MySQL:

>sudo service mysql restart

2) Create new 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'@'%';

3) In my case I needed to connect remotely from my Windows box to VirtualBox machine having Ubuntu. So I needed to allow port 3306 in iptables as follows:

>iptables -A INPUT -i eth0 -p tcp -m tcp --dport 3306 -j ACCEPT
9 7 4
38,600 points

Related questions

0 votes
1 answer 91 views
91 views
Problem: I am interested in learning MySQL. Currently I am facing the following error if I tried to add the index to my table using the MySQL Workbench: “Error Code: 2013. Lost connection to MySQL server during query.” I also noticed that above error appears only when I try to run long query. I want to know the away to increase my timeout value?
asked Jul 27, 2020 Raphael Pacheco 4.9k points
0 votes
1 answer 30 views
30 views
Problem : mysql server version for the right syntax to use near '' at line 1
asked Feb 13 Shovo210 14k points
0 votes
1 answer 1 view
1 view
Problem: How do I repair this failed connection: sqlstate[hy000] [Year 2003] On '127.0.0.1', I'm unable to link to the MySQL server (99) Can't bind to mysql server on '127.0.0.1' (111) error 2003 (hy000)?
asked 19 hours ago jamuna1 18.1k points
0 votes
1 answer 17 views
17 views
Problem : MySQL Error : got a packet bigger than 'max_allowed_packet' bytes
asked Feb 24 Shovo210 14k points
0 votes
1 answer 3 views
3 views
Problem: I'll make a submission for a response to my question. Please, I have searched the internet but have not found any useful material, and I am now having trouble continuing my studies.
asked Apr 1 rakib1 51.5k points
0 votes
1 answer 3 views
3 views
Problem: This started happening all of a sudden. I am just getting the critical error message. Does anyone know how to fix it?
asked Apr 1 zayed1 35.6k points
0 votes
1 answer 13 views
13 views
Problem: what is 5 star rating system in php mysql
asked Feb 18 kaash_kashi 1.2k points
0 votes
1 answer 5 views
5 views
Problem? How can i solve it ? please tell me
asked Mar 12 Ifra 24.4k points
0 votes
1 answer 45 views
45 views
Problem: Hi, I am new to php database operations. i have written the query and it shows the error column count doesn't match value count at row 1 mysql. INSERT INTO Student VALUES ('Name', 'last name''class');
asked Nov 16, 2020 prog_learner 2.5k points
0 votes
1 answer 1 view
1 view
Problem: What do I do about the error 2003 (hy000): can't bind to mysql server on '127.0.0.1' (111)?
asked 19 hours ago jamuna1 18.1k points