Jump to content

there's a problem in my database?!


mhmd

Recommended Posts

guys please help me, i can't connect my MTA server with mysql database i don't even know why the server doesn't access the mysql db. i have used this script to make the server access the database, but the debug gives me this failure : ERROR: mysql/mysql.lua:5: dbconnet failed; could not connect .... and i get this message in console : Connection with the MySQL database failed! .. that message you can see it in the script:....

script:

-- Connection functions 
local connection = nil 
  
local function connect( ) 
    connection = dbConnect( "mysql", "dbname=db20;host=127.0.0.1;port=3306;unix_socket=/var/run/mysqld/mysqld.sock", "db20", "65wb3anm6wv3ck75peei3", "share=1" ) 
    if connection then 
        outputConsole ( "Server is now connected with the MySQL database!", 1 ) 
        return true 
    else 
        outputConsole ( "Connection with the MySQL database failed!", 1 ) 
        return false 
    end 
end 
addEventHandler ( "onResourceStart", getResourceRootElement(getThisResource()), connect ) 
  
-- Exported functions 
function query( ... ) 
    if connection then 
        local qh = dbQuery( connection, ... ) 
        local result = dbPoll( qh, -1 ) 
        return result 
    else 
        return false 
    end      
end 
  
-- Get a single row from the database 
function querySingle( str, ... ) 
    if connection then 
        local result = query( str, ... ) 
        if type(result) == 'table' then 
            return result[1] 
        end 
        return result 
    else 
        return false 
    end 
end 
  
-- DB exec as used 
function exec( str, ... ) 
    if connection then 
        local qh = dbExec( connection, str, ... ) 
        return qh 
    else 
        return false 
    end 
end 

meta:

    "mysql" version="1.0.0" type="script" name="mysql" description="MySQL config resource" /> 
     
    

and this is some information about my, mysql database:

Host: ca1.delux-host.com 
Username: db20 
Password: 65wb3anm6wv3ck75peei3 
Database: db20 

so please could anyone help me? :mrgreen:

Link to comment

The syntax for dbConnect is like this:

element dbConnect ( string databaseType, string host [, string username = "", string password = "", string options = "" ] ) 

You are trying to connect to a local database on your Linux server while those login details (Which is extremely stupid to post in a public forum like this) goes to an external database hosting company of some kind. Now which one are you using?

If you're using a local database you may need to reinstall it and make sure the service is running, see this for more info about that: http://wiki.albonius.com/wiki/LAMP_Server

If you're using an external host for your database just update the syntax with the correct login details,

IMPORTANT Do not forget to change your database password otherwise anyone can hack it.

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