mysql: connection refused when trying to connect to localhost using remote IP

后端 未结 3 1231
隐瞒了意图╮
隐瞒了意图╮ 2020-12-10 04:26

When I try to connect to a local mysql database using it\'s remote ip-address I get a access denied. When I try to connect to that same database from an external machine, it

相关标签:
3条回答
  • 2020-12-10 04:31

    This particular issue can be caused by host name resolution.

    I have resolved it in my particular case by deleting this variable from my my.cnf config file:

    skip-name-resolve

    Either remark the variable by placing a pound sign # or just delete it from your my.cnf after making sure you back it up, of course.

    0 讨论(0)
  • 2020-12-10 04:33

    I found the solution to my problem myself, but I still don't quite understand why it didn't work:

    I granted privileges to that user on the hosts % and localhost:

    # Before
    +-----------------+------------+
    | Host            | User       |
    +-----------------+------------+
    | %               | username   |
    | localhost       | username   |
    +-----------------+------------+
    

    With these settings I got the results I showed above. When I granted privileges to that user on host it suddenly did work.

    # After
    +-----------------+------------+
    | Host            | User       |
    +-----------------+------------+
    | %               | username   |
    | localhost       | username   |
    | <myIpAddress>   | username   |
    +-----------------+------------+
    

    Apparently % does work for remote connections, but not for local connections.

    0 讨论(0)
  • 2020-12-10 04:42

    Try to edit/add bind-address = 0.0.0.0 to your [mysqld] section of your /etc/mysql/mysql.conf.d/mysqld.cnf file and restart MySQL Service.

    0 讨论(0)
提交回复
热议问题