Can connect to database, but cant query?

Hello facepunch

I noticed that my server gives errors about the database, it can connect but cannot query, first I thought there was a firewall problem with vilayer or something, but then they said the port is not blocked. So I tried to query something from my local pc, and the result was, that tmysql4 could connect, but as soon as the query was ran, it didn’t go any further, the user got full access to the database though…

MySQL log(Error log is empty)

160203  0:15:35	  188 Connect	DATABASE@IPADDRESS on DATABASE
		  189 Query	SELECT * FROM actions

Function(*Ignore function names etc, since I just ripped that part from an old addon to test it real quick)

pltceranks = pltceranks or {}
--	Database stuffs
function pltceranks.connecttodb()
	print("[PLTCE Ranks] - Connecting to database.")
	pltceranks.db, pltceranks.err = tmysql.initialize("SOMESHITTYIP", "DATABASEUSER", "DATABASEPASSWORD", "DATABASE", 3306)
	if pltceranks.db and !pltceranks.err then
		print("[PLTCE Ranks] - Connected to database.")
		pltceranks.db:Query("SELECT * FROM actions", function(results)
			PrintTable( results[1].data )
		print("[PLTCE Ranks] - Connection to database failed! '"..pltceranks.err.."'")


[PLTCE Ranks] - Connecting to database.
[PLTCE Ranks] - Connected to database.

Nothing else. the whole query function doesnt get ran, since anyhting I do in it, wont get used, not even like print(‘test’). I hope you really can help me there…

IF IT REALLY MATTERS: We’re using Plesk Web Pro on our server, and I tried it with, and without plesks firewall(firewall obviously allowed mysql), both results were the same, bind-address is & the plesk webconfig says remote connections are allowed.

Better post this in the official tmysql release thread instead

Try spawning a bot. Tmysql works by hooking the lua function tmysql.PollAll with the think hook. The think hook will only execute when the server isn’t in hibernation mode.
Although you can call this function yourself and it will work :slight_smile:

Update - Now it prints the query, I dont know why(since I didnt change anything on the vps), could it be the server somehow was delayed? (didnt even need to spawn a bot), I cant test it live on the server yet, since the owner isn’t on to reboot it, but yeah.

Not sure if you can connect and query within the same function. You should intialize in another function then called db:connect or db:disconnect etc.

it works completely fine in the same function, has nothing to do with it.