0

I have a mysql database running on my home computer and I want to access it from other networks (a laptop when I leave the house).

I followed a few posts and set up privileges:

+-----------------------------------------------------------+
| Grants for test@%                                         |
+-----------------------------------------------------------+
| GRANT USAGE ON *.* TO 'test'@'%'                          |
| GRANT ALL PRIVILEGES ON `database`.`table` TO 'test'@'%'  |
+-----------------------------------------------------------+

I am using SQLAlchemy to connect to the DB:

engine = create_engine('mysql://test:my_password@my_home_computer_ip_address:3306/table')

However I am getting this error:

sqlalchemy.exc.OperationalError: (_mysql_exceptions.OperationalError) (2003, "Can't connect to MySQL server on 'my_ip_address' (61)")

What am I doing wrong?

4
  • 2
    is that port open on your firewall? Commented Oct 2, 2017 at 14:16
  • OoO...good call. Let me check. Commented Oct 2, 2017 at 14:17
  • Leaving MySQL open is an invitation to trouble. You may want to open SSH with password authentication disabled instead and use that to tunnel in as SSH is generally less vulnerable to attacks than MySQL. Remember the default MySQL protocol is not encrypted. Commented Oct 2, 2017 at 15:53
  • Here's a generic answer with most of the requirements: Successfully connect Client to MySQL server Commented Oct 2, 2017 at 18:04

2 Answers 2

1

Two things always to check when accessing some not working service on remote computer.

  1. Can you ping this computer?
  2. Can you telnet to service (telnet my_sql_host my_sql_port)?

If there is fail on first step your network configuration is probably wrong. Fail on second step suggest firewall or service misconfiguration.

There is still possibility that there is another source of problem, but these are the most basic checks.

Sign up to request clarification or add additional context in comments.

5 Comments

for telnet, my_sql_host is my ip address?
I got a connection refused for telnet ip_address 3306
It's address of my_home_computer_ip_address
So there might be problem with firewall or with service. Is this machine that has mySQL server running on Linux?
I don't have MacOS - but according to internet you can check running ports with netstat. netstat -tlnp. Check if mysql is listening on 3306
0

Here's a generic answer to MySQL connection problems from the outside:

MYSQL Connection

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.