• Register
0 votes
99 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 58 views
58 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 10 views
10 views
Problem: I recently copied my mysql database to a new data directory and changed a few settings. I also accidentally deleted my / home / user directory and enjoyed recreating the fair. Now I can connect to mysql from the command line, but I cannot connect via phpMyAdmin. I ... phpto: $cfg['Servers'][$i]['host'] = '127.0.0.1'; // previously 'localhost' I also tried unsuccessfully FLUSH PRIVILEGE.
asked Dec 30, 2020 sasha 5.3k points
0 votes
1 answer 19 views
19 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 44 views
44 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, 2020 jwilliam 3.9k points
0 votes
1 answer 185 views
185 views
Problem : I am getting following error in my error log file [18-Nov-2019 19:09:55 UTC] PHP Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[HY000] [1040] Too many connections' in /home/root/products/db.php:2 Stack trace: /home/ ... ', 'root', '**somePassword**'); $db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); $db->setAttribute(PDO::ATTR_EMULATE_PREPARES, false);
asked Nov 20, 2019 peterlaw 6.9k points
0 votes
1 answer 71 views
71 views
Problem: Just to brief the title, I want to make a bar chart that will read data from a database table using MySql, and auto adjust the height to fit the new data. The data enters the database through the Arduino microcontroller, so data is repeatedly added ... data and increase its height according to it. Is there a way to do this without constantly refreshing the webpage every 0.5 seconds?
asked Dec 7, 2020 sasha 5.3k points
0 votes
1 answer 15 views
15 views
Problem: I need to filter my list of cities based on the country that I selected from the dropdown list. I'm new to PHP so I do not know much about how to do it. I already have a table of cities. Also, I need to know how to connect to the database. Here is the display that I want to show ... > </thead> <tbody> <tr> <td>City 1</td> <td>123891 SQ KM</td> <td>1.5 Million</td> </tr> </tbody> </table>
asked Nov 12, 2020 Grace Butan 340 points
0 votes
1 answer 32 views
32 views
Problem: I need to insert the json file to mysql table. I pasted my json file here for you to review so that someone can help me how to do this. { "Employees" : [ { "userId":"jmitchel", "jobTitle":"Developer", "firstName":"James", "lastName":"Mitchel", " ... ":"JosephSon", "jobTitle":"Program Directory", "firstName":"Joseph", "lastName":"Son", "emailAddress":"*Emails are not allowed*" } ] }
asked Nov 9, 2020 Reina Joy 360 points
0 votes
1 answer 17 views
17 views
Problem: I need to filter mysql records via search text input. I need to search either partly or full city or country of my transactions table. What do I do? Do I need to have two text input? Here is my code: <?php $conn = new mysqli($servername, $username, $password, ... tr> <?php } ?> </tbody> </table> Is there any possiblity also that my page will not refresh when I submit the search form?
asked Nov 9, 2020 Reina Joy 360 points
0 votes
2 answers 29 views
29 views
Problem Hello Kodlogs, I am looking to store json data in mysql using php. How can I achieve this? Thanks
asked Nov 3, 2020 hashq 1.1k points