Jump to content

Help with MYSQL


SmileFire

Recommended Posts

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

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 by MrTasty
Link to comment
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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...