Jump to content

Mysql problem


Ferriejxl

Recommended Posts

Hi!

Got some problems with my server, I have a local mysql server, but when im connecting server to it it wont connect!

He give's me this error

[2011-07-22 11:44:07] WARNING: mysql\connection.lua:16: Access denied @ 'mysql_connect'

[2011-07-22 11:44:08] ERROR: call: Failed, the resource mysql isn't running [string "?"]

I tried to get another connection script but it wont help, At the moment the script cant connect he turn automatic the resource mysql off!

what im doing wrong here??

This is the connection.lua

-- connection settings 
local hostname = get( "hostname" ) or "localhost" 
local username = get( "username" ) or "mta" 
local password = get( "password" ) or "12345" 
local database = get( "database" ) or "mta" 
local port = tonumber( get( "port" ) ) or 3306 
  
-- global things. 
local MySQLConnection = nil 
local resultPool = { } 
local sqllog = false 
local countqueries = 0 
  
-- connectToDatabase - Internal function, to spawn a DB connection 
function connectToDatabase(res) 
    MySQLConnection = mysql_connect(hostname, username, password, database, port) 
     
    if (not MySQLConnection) then 
        if (res == getThisResource()) then 
            cancelEvent(true, "Cannot connect to the database.") 
        end 
        return nil 
    end 
     
    return nil 
end 
addEventHandler("onResourceStart", getResourceRootElement(getThisResource()), connectToDatabase, false) 
     
-- destroyDatabaseConnection - Internal function, kill the connection if theres one. 
function destroyDatabaseConnection() 
    if (not MySQLConnection) then 
        return nil 
    end 
    mysql_close(MySQLConnection) 
    return nil 
end 
addEventHandler("onResourceStop", getResourceRootElement(getThisResource()), destroyDatabaseConnection, false) 
  
-- do something usefull here 
function logSQLError(str) 
    local message = str or 'N/A' 
    outputDebugString("MYSQL ERROR "..mysql_errno(MySQLConnection) .. ": " .. mysql_error(MySQLConnection)) 
    exports['logs']:logMessage("MYSQL ERROR ! [QUERY] " .. message .. " [ERROR] " .. mysql_errno(MySQLConnection) .. ": " .. mysql_error(MySQLConnection), 24) 
end 
  
function getFreeResultPoolID() 
    local size = #resultPool 
    if (size == 0) then 
        return 1  
    end 
    for index, query in ipairs(resultPool) do 
        if (query == nil) then 
            return index 
        end 
    end 
    return (size + 1) 
end 
  
------------ EXPORTED FUNCTIONS --------------- 
  
function ping() 
    if (mysql_ping(MySQLConnection) == false) then 
        -- FUU, NO MOAR CONNECTION 
        destroyDatabaseConnection() 
        connectToDatabase(nil) 
        if (mysql_ping(MySQLConnection) == false) then 
            logSQLError() 
            return false 
        end 
        return true 
    end 
  
    return true 
end 
  
function escape_string(str) 
    if (ping()) then 
        return mysql_escape_string(MySQLConnection, str) 
    end 
    return false 
end 
  
function query(str) 
    if sqllog then 
        exports['logs']:logMessage(str, 24) 
    end 
    countqueries = countqueries + 1 
     
    if (ping()) then 
        local result = mysql_query(MySQLConnection, str) 
        if (not result) then 
            logSQLError(str) 
            return false 
        end 
  
        local resultid = getFreeResultPoolID() 
        resultPool[resultid] = result 
        return resultid 
    end 
    return false 
end 
  
function unbuffered_query(str) 
    if sqllog then 
        exports['logs']:logMessage(str, 24) 
    end 
    countqueries = countqueries + 1 
     
    if (ping()) then 
        local result = mysql_unbuffered_query(MySQLConnection, str) 
        if (not result) then 
            logSQLError(str) 
            return false 
        end 
  
        local resultid = getFreeResultPoolID() 
        resultPool[resultid] = result 
        return resultid 
    end 
    return false 
end 
  
function query_free(str) 
    local queryresult = query(str) 
    if  not (queryresult == false) then 
        free_result(queryresult) 
        return true 
    end 
    return false 
end 
  
function rows_assoc(resultid) 
    if (not resultPool[resultid]) then 
        return false 
    end 
    return mysql_rows_assoc(resultPool[resultid]) 
end 
  
function fetch_assoc(resultid) 
    if (not resultPool[resultid]) then 
        return false 
    end 
    return mysql_fetch_assoc(resultPool[resultid]) 
end 
  
function free_result(resultid) 
    if (not resultPool[resultid]) then 
        return false 
    end 
    mysql_free_result(resultPool[resultid]) 
    table.remove(resultPool, resultid) 
    return nil 
end 
  
-- incase a nub wants to use it, FINE 
function result(resultid, row_offset, field_offset) 
    if (not resultPool[resultid]) then 
        return false 
    end 
    return mysql_result(resultPool[resultid], row_offset, field_offset) 
end 
  
function num_rows(resultid) 
    if (not resultPool[resultid]) then 
        return false 
    end 
    return mysql_num_rows(resultPool[resultid]) 
     
end 
  
function insert_id() 
    return mysql_insert_id(MySQLConnection) or false 
end 
  
function query_fetch_assoc(str) 
    local queryresult = query(str) 
    if  not (queryresult == false) then 
        local result = fetch_assoc(queryresult) 
        free_result(queryresult) 
        return result 
    end 
    return false 
end 
  
function query_rows_assoc(str) 
    local queryresult = query(str) 
    if  not (queryresult == false) then 
        local result = rows_assoc(queryresult) 
        free_result(queryresult) 
        return result 
    end 
    return false 
end 
  
function query_insert_free(str) 
    local queryresult = query(str) 
    if  not (queryresult == false) then 
        local result = insert_id() 
        free_result(queryresult) 
        return result 
    end 
    return false 
end 
  
function escape_string(str) 
    return mysql_escape_string(MySQLConnection, str) 
end 
  
function debugMode() 
    if (sqllog) then 
        sqllog = false 
    else 
        sqllog = true 
    end 
    return sqllog 
end 
  
function returnQueryStats() 
    return countqueries 
    -- maybe later more 
end 

Edited by Guest
Link to post

In the acl give the object ("resource.myql") an admin power. Just Press admin panel, then Resources, then Modify ACL, then double press admin at the top then press add object and type

resource.mysql 

Link to post

i cant come in game becose i cant login its all connected to db

Can i put it in acl.xml without going ingame?

I see the login panel but if i click on log in server give me error : Acces denied mysql_connect

Edited by Guest
Link to post

Ok done

    <group name="Admin"> 
        <acl name="Admin" /> 
        <acl name="Moderator" /> 
        <acl name="RPC" /> 
        <object name="resource.admin" /> 
        <object name="resource.mysql" /> 

Thats what i have done

but he still saying acces denied mysql_connect

I have done so much to make it work but it just won't do it in the mysql folder there is another .lua file

s_mysql.lua

username =  "mta" 
password =  "12345" 
db = "mta" 
host = "localhost" 
port = 3306 
  
function getMySQLUsername() 
    return username 
end 
  
function getMySQLPassword() 
    return password 
end 
  
function getMySQLDBName() 
    return db 
end 
  
function getMySQLHost() 
    return host 
end 
  
function getMySQLPort() 
    return port 
end 

Link to post

Yes im sure

Becose the mysql cant connect he automatic turns the recourse off

Do i need to make a special my sql group in the acl file like this

 <group name="mysql"> 
        <acl name="mysql" /> 
        <object name="resource.mysql" /> 

I have tried but this is also not working

Link to post

I cant go ingame becose the mysql cant connect so if i click on login nothing happens and give me error's in the server window

I cant open the chat ingame so i tried to type in in the server window but he says : Incorrect client for this command!

I now that i can put debugscript in the acl on true but on what cattegory i neet to put it? rpc?

This is the log file of my server

=========================================================== 
= Multi Theft Auto: San Andreas v1.0.5 
=========================================================== 
= Server name      : Default MTA server 
= Server IP address:  
= Server port      : 22003 
=  
= Log file         : ..reas/Server/mods/deathmatch/logs/server.log 
= Maximum players  : 32 
= MTU packet size  : 1264 
= HTTP port        : 22005 
=========================================================== 
[2011-07-24 12:17:52] Resources: 80 loaded, 0 failed 
[2011-07-24 12:17:52] Querying game-monitor.com master server... success! 
[2011-07-24 12:17:53] Querying backup master server... success! 
[2011-07-24 12:17:53] Starting resources... 
[2011-07-24 12:17:53] WARNING: mysql\connection.lua:69: Access denied @ 'shutdown' 
[2011-07-24 12:17:53] Start up of resource mysql cancelled by script 
[2011-07-24 12:17:53] ERROR: Unable to start resource mysql; Start up of resource cancelled by script 
  
[2011-07-24 12:17:53] ERROR: call: Failed, the resource global isn't running [string "?"] 
[2011-07-24 12:17:53] ERROR: call: Failed, the resource mysql isn't running [string "?"] 
[2011-07-24 12:17:53] ERROR: account-system\s_account_system_sapphire.lua:88: attempt to index local 'motdresult' (a boolean value) 
[2011-07-24 12:17:53] ERROR: call: Failed, the resource pool isn't running [string "?"] 
[2011-07-24 12:17:53] ERROR: call: Failed, the resource pool isn't running [string "?"] 
[2011-07-24 12:17:53] ERROR: animation-system\s_animation_system.lua:4: bad argument #1 to 'ipairs' (table expected, got boolean) 
[2011-07-24 12:17:53] ERROR: call: Failed, the resource mysql isn't running [string "?"] 
[2011-07-24 12:17:53] ERROR: call: Failed, the resource pool isn't running [string "?"] 
[2011-07-24 12:17:53] ERROR: call: Failed, the resource mysql isn't running [string "?"] 
[2011-07-24 12:17:53] ERROR: call: Failed, the resource mysql isn't running [string "?"] 
[2011-07-24 12:17:53] ERROR: call: Failed, the resource mysql isn't running [string "?"] 
[2011-07-24 12:17:53] ERROR: call: Failed, the resource mysql isn't running [string "?"] 
[2011-07-24 12:17:54] ERROR: call: Failed, the resource mysql isn't running [string "?"] 
[2011-07-24 12:17:54] ERROR: call: Failed, the resource mysql isn't running [string "?"] 
[2011-07-24 12:17:54] ERROR: call: Failed, the resource mysql isn't running [string "?"] 
[2011-07-24 12:17:54] ERROR: Couldn't find resource elevator-system. Check it exists. 
[2011-07-24 12:17:54] ERROR: call: Failed, the resource mysql isn't running [string "?"] 
[2011-07-24 12:17:54] ERROR: call: Failed, the resource mysql isn't running [string "?"] 
[2011-07-24 12:17:54] ERROR: call: Failed, the resource pool isn't running [string "?"] 
[2011-07-24 12:17:54] ERROR: call: Failed, the resource pool isn't running [string "?"] 
[2011-07-24 12:17:54] ERROR: call: Failed, the resource pool isn't running [string "?"] 
[2011-07-24 12:17:54] ERROR: call: Failed, the resource pool isn't running [string "?"] 
[2011-07-24 12:17:54] ERROR: call: Failed, the resource pool isn't running [string "?"] 
[2011-07-24 12:17:54] ERROR: call: Failed, the resource pool isn't running [string "?"] 
[2011-07-24 12:17:54] INFO: Stevie will spawn in 413 minutes. 
[2011-07-24 12:17:54] INFO: Giovanni will spawn in 413 minutes. 
[2011-07-24 12:17:54] ERROR: call: Failed, the resource pool isn't running [string "?"] 
[2011-07-24 12:17:54] ERROR: call: Failed, the resource pool isn't running [string "?"] 
[2011-07-24 12:17:54] ERROR: call: Failed, the resource pool isn't running [string "?"] 
[2011-07-24 12:17:54] ERROR: call: Failed, the resource pool isn't running [string "?"] 
[2011-07-24 12:17:54] ERROR: call: Failed, the resource pool isn't running [string "?"] 
[2011-07-24 12:17:54] ERROR: call: Failed, the resource pool isn't running [string "?"] 
[2011-07-24 12:17:54] ERROR: call: Failed, the resource pool isn't running [string "?"] 
[2011-07-24 12:17:54] ERROR: call: Failed, the resource pool isn't running [string "?"] 
[2011-07-24 12:17:54] ERROR: call: Failed, the resource pool isn't running [string "?"] 
[2011-07-24 12:17:54] ERROR: call: Failed, the resource pool isn't running [string "?"] 
[2011-07-24 12:17:54] ERROR: call: Failed, the resource pool isn't running [string "?"] 
[2011-07-24 12:17:54] ERROR: call: Failed, the resource pool isn't running [string "?"] 
[2011-07-24 12:17:54] ERROR: call: Failed, the resource pool isn't running [string "?"] 
[2011-07-24 12:17:54] ERROR: call: Failed, the resource pool isn't running [string "?"] 
[2011-07-24 12:17:54] ERROR: call: Failed, the resource pool isn't running [string "?"] 
[2011-07-24 12:17:54] ERROR: call: Failed, the resource mysql isn't running [string "?"] 
[2011-07-24 12:17:54] ERROR: call: Failed, the resource mysql isn't running [string "?"] 
[2011-07-24 12:17:54] Please wait... 
[2011-07-24 12:17:54] ERROR: call: Failed, the resource pool isn't running [string "?"] 
[2011-07-24 12:17:54] ERROR: gps-system\s_gps.lua:4: bad argument #1 to 'ipairs' (table expected, got boolean) 
[2011-07-24 12:17:54] ERROR: call: Failed, the resource pool isn't running [string "?"] 
[2011-07-24 12:17:54] ERROR: id-system\s_id_system.lua:31: bad argument #1 to 'ipairs' (table expected, got boolean) 
[2011-07-24 12:17:54] ERROR: call: Failed, the resource mysql isn't running [string "?"] 
[2011-07-24 12:17:54] ERROR: call: Failed, the resource mysql isn't running [string "?"] 
[2011-07-24 12:17:54] ERROR: call: Failed, the resource mysql isn't running [string "?"] 
[2011-07-24 12:17:54] ERROR: call: Failed, the resource mysql isn't running [string "?"] 
[2011-07-24 12:17:54] ERROR: call: Failed, the resource mysql isn't running [string "?"] 
[2011-07-24 12:17:54] WARNING: item-system\s_item_management.lua:12: Access denied @ 'mysql_connect' 
[2011-07-24 12:17:54] WARNING: item-system\s_item_system.lua:938: Access denied @ 'mysql_query' 
[2011-07-24 12:17:54] WARNING: item-system\s_item_system.lua:942: Access denied @ 'mysql_error' 
[2011-07-24 12:17:54] WARNING: item-system\s_item_system.lua:942: Bad argument @ 'outputDebugString' 
[2011-07-24 12:17:54] WARNING: item-system\s_item_system.lua:946: Access denied @ 'mysql_query' 
[2011-07-24 12:17:54] ERROR: item-system\s_item_system.lua:947: bad argument #1 to 'mysql_rows' (LuaBook.mysqlResult expected, got nil) 
[2011-07-24 12:17:54] ERROR: call: Failed, the resource pool isn't running [string "?"] 
[2011-07-24 12:17:54] ERROR: language-system\s_language_system.lua:111: bad argument #1 to 'ipairs' (table expected, got boolean) 
[2011-07-24 12:17:54] ERROR: Couldn't find resource logs. Check it exists. 
[2011-07-24 12:17:54] INFO: Lottery will be drawn in 353 minutes. 
[2011-07-24 12:17:54] ERROR: call: Failed, the resource mysql isn't running [string "?"] 
[2011-07-24 12:17:54] ERROR: call: Failed, the resource pool isn't running [string "?"] 
[2011-07-24 12:17:54] ERROR: call: Failed, the resource pool isn't running [string "?"] 
[2011-07-24 12:17:54] ERROR: call: Failed, the resource pool isn't running [string "?"] 
[2011-07-24 12:17:54] ERROR: call: Failed, the resource pool isn't running [string "?"] 
[2011-07-24 12:17:55] ERROR: call: Failed, the resource mysql isn't running [string "?"] 
[2011-07-24 12:17:55] ERROR: call: Failed, the resource mysql isn't running [string "?"] 
[2011-07-24 12:17:55] ERROR: call: Failed, the resource mysql isn't running [string "?"] 
[2011-07-24 12:17:55] ERROR: call: Failed, the resource mysql isn't running [string "?"] 
[2011-07-24 12:17:55] ERROR: call: Failed, the resource mysql isn't running [string "?"] 
[2011-07-24 12:17:55] ERROR: call: Failed, the resource mysql isn't running [string "?"] 
[2011-07-24 12:17:55] ERROR: call: Failed, the resource mysql isn't running [string "?"] 
[2011-07-24 12:17:55] ERROR: call: Failed, the resource mysql isn't running [string "?"] 
[2011-07-24 12:17:55] ERROR: call: Failed, the resource mysql isn't running [string "?"] 
[2011-07-24 12:17:55] ERROR: call: Failed, the resource mysql isn't running [string "?"] 
[2011-07-24 12:17:55] ERROR: shop-system\s_generalshop_system.lua:480: attempt to index local 'result' (a boolean value) 
[2011-07-24 12:17:55] ERROR: call: Failed, the resource mysql isn't running [string "?"] 
[2011-07-24 12:17:55] ERROR: call: Failed, the resource mysql isn't running [string "?"] 
[2011-07-24 12:17:55] ERROR: call: Failed, the resource mysql isn't running [string "?"] 
[2011-07-24 12:17:55] ERROR: Couldn't find resource toolstip-system. Check it exists. 
[2011-07-24 12:17:55] ERROR: call: Failed, the resource mysql isn't running [string "?"] 
[2011-07-24 12:17:55] INFO: loadAllVehicles failed 
[2011-07-24 12:17:55] ERROR: call: Failed, the resource mysql isn't running [string "?"] 
[2011-07-24 12:17:55] ERROR: call: Failed, the resource mysql isn't running [string "?"] 
[2011-07-24 12:17:55] ERROR: Couldn't find resource interior-system. Check it exists. 
[2011-07-24 12:17:55] Server started and is ready to accept connections! 
[2011-07-24 12:17:55] Type 'help' for a list of commands. 
[2011-07-24 12:17:56] WARNING: startup\s_startup.lua:10: Access denied @ 'restartResource' 
[2011-07-24 12:18:06] debugscript: Incorrect client type for this command 
[2011-07-24 12:18:15] debugscript: Syntax is 'debugscript <mode>' 
  

I i type : start mysql he give me this

[2011-07-24 12:31:28] Starting mysql 
[2011-07-24 12:31:28] WARNING: mysql\connection.lua:69: Access denied @ 'shutdown' 
[2011-07-24 12:31:28] Start up of resource mysql cancelled by script 
[2011-07-24 12:31:28] Stopping mysql 
[2011-07-24 12:31:28] start: Resource 'mysql' start was requested 
[2011-07-24 12:32:14] ERROR: call: Failed, the resource mysql isn't running [string "?"] 
[2011-07-24 12:33:14] ERROR: call: Failed, the resource mysql isn't running [string "?"] 

Im using Xamp, With local mysql db, if i upload another script with mysql it no problem no errors!

So it hink its something in the connection.lua

Link to post

Dude, You dont need any alc rights to this module. Pls check your facts before you post QAISJP. Take your resource folder and stick it somewhere safe, Reinstall the server module of mta 1.05, Then place your resource folder back. Start the server, then try to connect to it :)

Link to post

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...