possy_99 Posted May 27, 2014 Share Posted May 27, 2014 (edited) Hi, I'm trying to make a script that I can run on some networked computers which will populate a mysql database with certain information about the computer. This is my 1st real 'play' with mysql (with the exception of vbulletin/joomla/wp etc) but I've hit a bit of a brick wall. I'm using the UDF from this thread: '?do=embed' frameborder='0' data-embedContent>> I've installed Uniform server on one of the networked machines, been through mysql and checked binding etc, but the script will only work on the machine running as the server, when the server address is left blank it works on the server machine, but when I specify a server address (weather it be the server IP or machine name) it just won't connect. ie.. Local $strHost = "", $strUID = "user", $strPass = "pass", $strDB = "database" If Not _EzMySql_Startup() Then MsgBox(0, "Error Starting MySql", "Error: "& @error & @CR & "Error string: " & _EzMySql_ErrMsg()) Exit EndIf If Not _EzMySql_Open($strHost, $strUID, $strPass, $strDB, "3306") Then MsgBox(0, "Error opening Database", "Error: "& @error & @CR & "Error string: " & _EzMySql_ErrMsg()) Exit EndIf If Not _EzMySql_SelectDB("database") Then MsgBox(0, "Error setting Database to use", "Error: "& @error & @CR & "Error string: " & _EzMySql_ErrMsg()) Exit EndIf works fine when used on machine running the mysql server.. (but obviously not on other computers) Local $strHost = "192.168.122.101", $strUID = "user", $strPass = "pass", $strDB = "database" If Not _EzMySql_Startup() Then MsgBox(0, "Error Starting MySql", "Error: "& @error & @CR & "Error string: " & _EzMySql_ErrMsg()) Exit EndIf If Not _EzMySql_Open($strHost, $strUID, $strPass, $strDB, "3306") Then MsgBox(0, "Error opening Database", "Error: "& @error & @CR & "Error string: " & _EzMySql_ErrMsg()) Exit EndIf If Not _EzMySql_SelectDB("database") Then MsgBox(0, "Error setting Database to use", "Error: "& @error & @CR & "Error string: " & _EzMySql_ErrMsg()) Exit EndIf ..just comes back with a connection error. As a test, I also created a user/database on my paid webhost and tried connecting to that too.. same result.. error connecting. Can anyone help me out please..? even a different UDF..? Edited May 27, 2014 by possy_99 Link to comment Share on other sites More sharing options...
Jewtus Posted May 27, 2014 Share Posted May 27, 2014 (edited) Unless its automatically configured, I think you need to provide a port number if your going through the network. When I am working on my web services (no mysql but same basic logic) I can trigger to the machine, but I still need to provide a port number... EX localhost:4040 I googled it and it looks like Mysql uses port 3306 by default There may also be firewall configurations that are causing issues. I like to use Canyouseeme ( test ports, but its more for external network tests... depending on the router, there might be tools on the routers portal for network testing. try this: Local $strHost = "192.168.122.101:3306", $strUID = "user", $strPass = "pass", $strDB = "database" Edited May 27, 2014 by Jewtus Link to comment Share on other sites More sharing options...
possy_99 Posted May 27, 2014 Author Share Posted May 27, 2014 (edited) Hi Jewtus, thanks very much for your reply, the port number is defined after the _ezmysql startup function.. in amongst the 2nd IF in the code above, as per UDF instructions.. ; Syntax.........: _EzMySql_Open($Host, $User, $Pass, $Database = "", $Port = 0, $unix_socket = "", $Client_Flag = 0) I tried what you said though, but got 'unknown mysql server host' Edited May 27, 2014 by possy_99 Link to comment Share on other sites More sharing options...
Jewtus Posted May 27, 2014 Share Posted May 27, 2014 (edited) Ahh I didn't see that. You have tried hitting the machine manually (without using Autoit) to see if you can connect from the other machines? It will rule out any network issues (I almost always spend hours pounding my head against a desk when doing deployments and pushing to nodes, and the issue is almost always a networking issue for me) You could also try using {hostname} rather than the IP Edited May 27, 2014 by Jewtus Link to comment Share on other sites More sharing options...
gritts Posted May 27, 2014 Share Posted May 27, 2014 You could also test port access by attempting to telnet from a command prompt to your destination server and the port in question. telnet hostname portnum (ie. telnet 192.168.122.101 3306) the spaces should be there. Telnet client may not work if it has not been enabled as a windows feature. (Through the add remove programs, turn on windows feature) If the connection is good, you should see a command prompt with no text. (Or possibly some text confirming connectivity) Link to comment Share on other sites More sharing options...
possy_99 Posted May 27, 2014 Author Share Posted May 27, 2014 here some more tests: T:\_test>mysql -h c412 ERROR 2003 (HY000): Can't connect to MySQL server on 'c412' (10061) T:\_test>mysql -h 192.168.122.54 ERROR 2003 (HY000): Can't connect to MySQL server on '192.168.122.54' (10061) T:\_test>telnet c412 3306 Connecting To c412...Could not open connection to the host, on port 3306: Connec t failed T:\_test>telnet 192.168.122.54 3306 Connecting To 192.168.122.54...Could not open connection to the host, on port 33 06: Connect failed T:\_test>ping 192.168.122.54 Pinging 192.168.122.54 with 32 bytes of data: Reply from 192.168.122.54: bytes=32 time<1ms TTL=128 Reply from 192.168.122.54: bytes=32 time<1ms TTL=128 Reply from 192.168.122.54: bytes=32 time<1ms TTL=128 Reply from 192.168.122.54: bytes=32 time<1ms TTL=128 Ping statistics for 192.168.122.54: Packets: Sent = 4, Received = 4, Lost = 0 (0% loss), Approximate round trip times in milli-seconds: Minimum = 0ms, Maximum = 0ms, Average = 0ms I did a netstat -a on the server machine and it is listening on 3306..? Link to comment Share on other sites More sharing options...
Queener Posted May 28, 2014 Share Posted May 28, 2014 My guess would be permission. On SQL server side, you would need to add root user to % to represent log as root from any hostname. Msgbox(0, "Hate", "Just hate it when I post a question and find my own answer after a couple tries. But if I don't post the question, I can't seem to resolve it at all.") Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now