dam034 Posted October 1, 2017 Share Posted October 1, 2017 Dear users, I created a test resource called "prova". When I try to start it, I get this error: [12:50:25] start: Requested by Console [12:50:25] Resource 'prova' changed, reloading and starting [12:50:25] Starting prova [12:50:25] WARNING: [mie]/prova/mysql.lua:4: Bad usage @ 'dbConnect' [Can't connect to local MySQL s erver through socket '' (111)] [12:50:25] start: Resource 'prova' started As it appears, the problem is in the mysql.lua file, executed serverside, this is the code: db = nil function conn() db = dbConnect('mysql', 'dbname=mtasa;host=localhost;port=3306;', 'mtasa', '', "share=1") end function disc() destroyElement(db) end function segnalo(msg, tipo) dbExec(db, 'INSERT INTO provatab(testo, soldi, spotf) VALUES(?, ?, ?)', 'Msg-'..tostring(tipo)..': '..msg, 2500, 1) end function giraarma(prima, mo) dbExec(db, 'INSERT INTO provatab(testo, soldi, spotf) VALUES(?, ?, ?)', 'Arma da '..tostring(prima)..' a '..tostring(mo)..' - Chi: '..getPlayerName(source), 2500, 1) end addEventHandler('onResourceStart', getResourceRootElement(), conn) addEventHandler('onResourceStop', getResourceRootElement(), disc) addEventHandler("onPlayerChat", getRootElement(), segnalo) addEventHandler("onPedWeaponSwitch", getRootElement(), giraarma) I thought it could be a mysql problem, but when I try to access to my database via phpmyadmin on localhost server, I can access without problems. What can it be? Please help! Link to comment
Simple0x47 Posted October 1, 2017 Share Posted October 1, 2017 You are missing the unix socket boy. If you don't know where it is, just connect to the mySQL by using your host public IP. Link to comment
dam034 Posted October 1, 2017 Author Share Posted October 1, 2017 Actually, I'm developing/testing my MTA server in LAN, then without public IP, and then I don't want to grant mysql connections outside localhost, due to security problems. How can I fix this issue (unix socket) using localhost address? Thanks Link to comment
dam034 Posted October 1, 2017 Author Share Posted October 1, 2017 I solved the problem changing the old dbConnect() code with this: db = dbConnect('mysql', 'dbname=mtasa;host=localhost;port=3306;unix_socket=/var/run/mysqld/mysqld.sock;charset=utf8;', 'mtasa', '', "share=1;autoreconnect=1;") Now if you want, you can trash this topic. Bye! 1 Link to comment
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