mushclient and mysql/lua

Posted by Lilbopeep on Mon 01 Oct 2012 05:08 AM — 5 posts, 20,928 views.

USA #0

I tried following the instructions on various parts of the website but most of it seems fairly old so just double checking some things..

I have lua5.1.dll, mysql.dll, and libmySQL.dll all installed in the same directory as my mushclient.exe

I have changed global properties of lua to reflect trust_all_worlds = true

I reloaded the script file


when I try to run

 assert (package.loadlib ("mysql.dll", "luaopen_luasqlmysql")) ()

 env = assert (luasql.mysql())
    
 con = assert (env:connect ("tumbleweed_db", "tumble", "password", "mudsite.com"))

 -- retrieve a cursor
 cur = assert (con:execute ("SELECT count(*) from users" ))

 -- print all rows, the rows will be indexed by field names
 row = cur:fetch ({}, "a")

 while row do
   table.foreach (row, print)
   row = cur:fetch (row, "a")
 end

 -- close everything
 cur:close()
 con:close() 
 env:close()

I get


Immediate execution
[string "Immediate"]:6: LuaSQL: Error connecting to database. MySQL: Can't connect to MySQL server on 'mudsite.com' (10061)
stack traceback:
        [C]: in function 'assert'
        [string "Immediate"]:6: in main chunk


Have things changed? I can't find much information on this subject that is recent. thanks!
Australia Forum Administrator #1

$ mysql -utumble -ppassword -hmudsite.com
ERROR 2003 (HY000): Can't connect to MySQL server on 'mudsite.com' (111)


When I connect with the command-line interface I get the same results. I presume "password" isn't the real password. Try using the command-line interface and see if that works.
USA #2
well yeah, I just didnt give out my username and password over the internet..

I can log into my server no problem, however when I provide the hostname option I get an error, I wonder if the problem is related to networking and am checking with system admin to see if remote mysql access is blocked.

Thanks nick
#3
You tried using the ip instead of mudsite.com
#4
Mysql Error 10061 is "Connection Refused". It means it is connecting, but the server is actively refusing the connection. This isn't a Lua problem, but an issue with your server. I'm going to assume from hereout your MySQL server is on a linux box, but feel free to correct me and I can update my instructions. Open a terminal or SSH into the box MySQL is running on and enter the following:

netstat -ape | grep mysql

You should see a listening connection. Something like

tcp        0      0 *:mysql                     *:*                         LISTEN      mysql      9480       2657/mysqld


If you get nothing, your service isn't running and you'll want to start it (I assume you've checked that, but saying it just in case).
If it's saying it's listening to localhost instead of *, you won't be able to access it from outside machines, or possibly even on the same machine unless you use a loopback (127.0.0.1 or localhost), and will need to update your configuration to allow it.
If neither of those are the issue, check iptables for any rules that could be blocking outside connections from connecting on that port (As a note, certain distributions have been released with default rules in IPtables that do this, which can cause issues. Fedora comes to mind.)

EDIT: As a note, if this is MySQL being provided from a webhosting account, chances are it is blocked for security issues. That tends to be a standard practice. Also, just noticed you were contacting your network admin, so most of this information will likely be redundant. If that is the case, my apologies.