Can`t connect to mysql server on X.X.X.X on Windows

爱⌒轻易说出口 提交于 2019-12-25 01:45:57

问题


As the title says I want to connect remotely to mysql and it is on windows server but I got this error message.

Cant connect to mysql server on X.X.X.X I am tring it with HeidiSql

I have MariaDB installed.

Also I can connect to server using remote connection.

Server is running and can connect to mysql localy

What have I tried:

  1. I located my my.ini file and checked that I dont have one of these commands:

Skip-networking

bind-address = some IP

I didnt have them there in the first place

  1. I logged in my MariaDB terminal and granted all permisions to user using this:

    GRANT ALL PRIVILEGES ON *.* TO 'root'@'192.168.100.%' IDENTIFIED BY 'my-new-password' WITH GRANT OPTION;

  2. I have added port 3306 to windows firewall

  3. I guess it is worth mentioning that I cant ping that server either if I do

ping X.X.X.X

it returns:

Pinging X.X.X.X with 32 bytes of data: Request timed out. Request timed out. Request timed out. Request timed out. Ping statistics for X.X.X.X: Packets: Sent = 4, Received = 0, Lost = 4 (100% loss),

I have spent many hours on forums and tried all instructions but still cant connect.

Any help would be much appreciated!


回答1:


The detailed problem can be from two different causes:

First option:

MySQL is binded to 127.0.0.1 or no ip at all. Check netstat on windows cmd for locating 3306 port opened to mysql process and binded to your network LAN interface or 0.0.0.0 (not to loopback / 127.0.0.1 // ::1)

For check netstat, use netstat -a -n -o, you can see in the response the PID of the process too.

For check MySQL is working on the same machine, try to connect from local console using mysql -h 127.0.0.1 (for localhost connection) or mysql -h (your LAN IP) (If you have mysql binded only to your LAN IP address).

Second option:

If first test are OK. Maybe windows firewall is not configured correctly. Try to disable windows firewall (double check disabling it). The error response on your question are because windows firewall are active and blocking connections. When you have verified you can reach 3306 with firewall off, enable it and configure. Check always you're opening the port on the required network profile (Remember, windows firewall can have different rules for private / public connections).

For check firewall correctly configured, try to access to the 3306 port on the computer from another comp on the LAN.

If you have a huge LAN network with VLANs and similar technologies, check your routing topology. Also, remember always for initial checks, disable windows firewall. Your ping are failing because firewall are enabled.



来源:https://stackoverflow.com/questions/53608064/cant-connect-to-mysql-server-on-x-x-x-x-on-windows

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!