[Release] MySQL Async Library - 3.0.8

dev
mysql
basemods

#366

Hello!

Since yesterday i work for the first time on a server for the game FiveM.

I wanted to install Cops_FiveM what also needed MySQL.

This error i cannot figure out what i did wrong.

Already one time i delete all database.

[ERROR] [MySQL] An error happens on MySQL for query "SELECT rank,dept FROM police WHERE identifier = 'steam:1100001006a4aef' {@identifier=steam:1100001006a4aef}": You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ',dept FROM police WHERE identifier = 'steam:1100001006a4aef'' at line 1


#367

just tick your stuff properly.


#368

What you mean, the MYSQL software?


#369

Release: 3.0.0

Since the lack of “doesn’t work”, I highly recommend everyone updating mysql-async to 3.0, if they run their server on a windows system.

On linux you should stick with a 2.X version.


#370

@zr0iq why cant you make it work on linux?


#371

Linux has some weird issues with v8 / node. It is not maybe not garbage collecting, thus your servers would go out of memory sooner or later. If you run on low query counts for like 4h-6h before rebooting the fivem server, it might be fine (on newer builds post 760). And I got some report of potential freezes, which I could not confirm on a newer version (a 778 build).


Difference between Linux and Windows
#372

Using the 3.0 on windows gives me this message on start up

Error loading script mysql-async.js in resource TODO: TypeError: global.exports is not a function
stack:
TypeError: global.exports is not a function
at Object. (mysql-async.js:5058:8)
at webpack_require (mysql-async.js:20:30)
at mysql-async.js:84:18
at mysql-async.js:87:10
Failed to load script mysql-async.js.


#373

Which server version are you running?

Make sure you are running one of the newest versions:

https://runtime.fivem.net/artifacts/fivem/build_server_windows/master/


#374

updating worked! thanks a lot :slight_smile:


#375

I’ve updated mysql-async to 3.0 and this is giving this error I’m trying everything I know more or less nothing makes it work already 3 days is difficult rsrsrs

Line of Code

RegisterServerEvent('gcPhone:_internalAddMessage')
AddEventHandler('gcPhone:_internalAddMessage', function(transmitter, receiver, message, owner, cb)
Line 170    cb(_internalAddMessage(transmitter, receiver, message, owner))
end)

function _internalAddMessage(transmitter, receiver, message, owner)
    local Query = "INSERT INTO phone_messages (`transmitter`, `receiver`,`message`, `isRead`,`owner`) VALUES(@transmitter, @receiver, @message, @isRead, @owner);"
    local Query2 = 'SELECT * from phone_messages WHERE `id` = (SELECT LAST_INSERT_ID());'
	local Parameters = {
        ['@transmitter'] = transmitter,
        ['@receiver'] = receiver,
        ['@message'] = message,
        ['@isRead'] = owner,
        ['@owner'] = owner
    }
Line 183 	return MySQL.Sync.fetchAll(Query .. Query2, Parameters)[1]
end


#376

Been having huge issues getting this working. last error was access this database when the server started and i fixed this by changing the resource.lua file to server_script ‘@mysql-async/lib/MySQL.lua’ instead of mysql-async.js

Now when any user logins i get this error:

Error running system event handling function for resource esplugin_mysql: citizen:/scripting/lua/scheduler.lua:41: Failed to execute thread: citizen:/scripting/lua/scheduler.lua:657: No such export mysql_fetch_all in resource mysql-async
stack traceback:
[C]: in function ‘error’
citizen:/scripting/lua/scheduler.lua:657: in metamethod ‘__index’
@mysql-async/lib/MySQL.lua:143: in field ‘fetchAll’
server.lua:15: in upvalue ‘handler’
citizen:/scripting/lua/scheduler.lua:175: in function citizen:/scripting/lua/scheduler.lua:174
stack traceback:
[C]: in function ‘error’
citizen:/scripting/lua/scheduler.lua:41: in field ‘CreateThreadNow’
citizen:/scripting/lua/scheduler.lua:174: in function citizen:/scripting/lua/scheduler.lua:138

any ideas on how to fix


#377

I found the error in LAST_INSERT_ID () that is no longer in the mysql-async to 3.0 stream. Someone knows how to sort or declare it in this version


#378

@WayCraft mysql 3.0.0 forces that only one query per query works. So if you want to remove that limit you put an option there. Which I would not recommend.

But the way you do it is pretty bad. You know what you inserted right, why are you trying to select it again in the same line? If you would do that, you would first run an insert query, which automatically returns the last insert id, and then from that query select, but it is still… :man_shrugging:

MySQL.Async.insert('insert ...', {}, function(id)
  MySQL.Async.fetchScalar('select * from phone_messages where id = @id', {['id']=id}, function (result)
-- here you got your result, or do it sync
  end)
end)

That should have never have changed. This is how mysql-async always worked, in any version :cry: . Do I need to update the documentation?


#379

Use the mysql ready or make sure mysql-async gets started first.


#380

good still giving the error more now in another place because I need the results in return — [1] or some way to fit the [1] I’m here trying with your idea that it worked out without the return [1] I do not know how to command the code recognize this without doing the way that this other thing would be I add the old insert.cs more I tried some things and without success

I’m sorry for using the translator

return MySQL.Sync.fetchAll(Query … Query2, Parameters)[1]


#381

i have a problem, everytime i trigger a server event with a mysql command it get triggered like 500 times instead of only 1… what can i do? creating a character in db i get my char 500 times XD


#382

No i’m just throwing mud hoping something sticks. the issue is that the mysql database isn’t being seen by the fivem server. people say i have to deauthorise the mysql database but i don’t know how. Any thoughts?


#383

@Waycraft i told you to use the sync functions, like this:

id = MySQL.Sync.insert('insert ...', {})  
result = MySQL.Sync.fetchAll('select * from phone_messages where id = @id limit 1', {['id']=id})[1]
end)

@manups4e did you try canceling the event? maybe the issue comes from one of the other resources? that call the event.

@aaron_roberts I suspect the database is just setup fresh?

GRANT USAGE ON essentialmode.* TO 'esxuser'@'localhost' IDENTIFIED BY PASSWORD 'password';
FLUSH PRIVILEGES;

if that is not helping, then I highly suspect you never setup a user correctly for your database in the first place. Also if you have this error:

citizen:/scripting/lua/scheduler.lua:41: Failed to execute thread: citizen:/scripting/lua/scheduler.lua:657: No such export mysql_fetch_all in resource mysql-async

instead of what you are sayin’ in the last post I will get really mad.


#384

Hiya team,

Just something I’ve noticed with the new connection string (not sure if it has been mentioned previously) but if you have a “@” character in your password it’ll cock up the rest of the string because it’ll take that first “@” as the call to the host, if that makes sense? Someone else might be able to say it better but basically if your connection string looks like mysql://username:pass@wordsecure@127.0.0.1/essentialmode?dateStrings=true you’ll run into issues with the “wordsecure” part of your password being mistaken for the host! Sorry if that’s hard to read, not an expert with this stuff but just something I’ve noticed!

Cheers,
Grew.


#385

I’ll make sure to parse both types of connection strings. Hopefully today, if not next week to proper settings. It never occured to me somehow.

Thanks.