• Register
0 votes

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

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       =

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 40 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 Raphael Pacheco 4.9k points
0 votes
1 answer 28 views
Problem : I have a Stored procedure like below: CREATE PROCEDURE MyProG() BEGIN SELECT * FROM `hs_hr_employee_leave_quota`; END But it gives me the below error: #1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 3 What does this error mean? What is wrong with my line number 2?
asked Jan 30 jwilliam 3.9k points
0 votes
1 answer 3 views
Hello, I have a running PHP code that I was working. This code is used to upload an image to the folder "uploads/". It is working fine but I want to make sure that only image is uploaded. Here's my working code: <?php $folder = "uploads/"; $filename = basename ... index". Could you also help me to address this? I also wanted to make sure that the file that was uploaded is saved into my database.
asked 12 hours ago RJ Lam 180 points
0 votes
1 answer 5 views
Hello, can somebody show me a PHP code snippet that demonstrate on how to search and display the data from the database? The table below demonstrate the format as well! Name Work Age Cell Labourer 30 Jun Associate 34 Riza Cashier 36 As you can see, the example above have one thing ... above 30. Let us say that I have 100 people and I just want to list those whose age are from 30 to 40. Thank you!
asked Oct 12 robin_gallo 300 points
0 votes
1 answer 7 views
Hi, I have a small php project. I need a php class that will enable me to retrieve the information from a database so that I can display in a table as shown in this html code: <!DOCTYPE html> <html> <head> <title>List of Cars</title> </head> <body> <table> <tr> <th>Year</th> <th>Brand</ ... >AUDI Q2 2020</td> </tr> <tr> <td>2020</td> <td>Volvo</td> <td>Xc60 2020</td> </tr> </table> </body> </html>
asked Oct 11 azriel 530 points