SmileFire Posted August 25, 2019 Share Posted August 25, 2019 Hello everyone, can you help with connecting to MYSQL? It connects on a socket, but I need to change somehow on connection on IP. Here's the code: local unix_socket, host = unix_socket, host local dbname, user, password = dbname, user, password local mainDB function connect() local startTick = getTickCount() mainDB = dbConnect("mysql", (unix_socket and "unix_socket="..unix_socket or "host="..host)..";dbname="..dbname, user, password) if (mainDB) then outputDebugString("[MYSQL] Connection: "..getTickCount()-startTick.." ms.") else outputDebugString("[MYSQL][ERROR] Connection failed!", 1) setTimer(connect, 5000, 1) end end connect() Link to comment
Addlibs Posted August 26, 2019 Share Posted August 26, 2019 (edited) If you nullify the unix_socket variable (nil or false), it will use the 'host' variable. Put the IP you want in host. mainDB = dbConnect("mysql", (unix_socket and "unix_socket="..unix_socket or "host="..host)..";dbname="..dbname, user, password) local unix_socket = nil local host = "255.255.255.255" -- your ip here mainDB = dbConnect("mysql", (unix_socket and ("unix_socket="..unix_socket) or ("host="..host))..";dbname="..dbname, user, password) Edited August 26, 2019 by MrTasty Link to comment
SmileFire Posted August 26, 2019 Author Share Posted August 26, 2019 5 hours ago, MrTasty said: If you nullify the unix_socket variable (nil or false), it will use the 'host' variable. Put the IP you want in host. mainDB = dbConnect("mysql", (unix_socket and "unix_socket="..unix_socket or "host="..host)..";dbname="..dbname, user, password) local unix_socket = nil local host = "255.255.255.255" -- your ip here mainDB = dbConnect("mysql", (unix_socket and ("unix_socket="..unix_socket) or ("host="..host))..";dbname="..dbname, user, password) Thx you, you really good man) 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