Raised This Month: $32 Target: $400
 8% 

Solved [HELP] MySQL Error


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
SpirT
Senior Member
Join Date: Sep 2018
Location: Portugal
Old 04-03-2020 , 13:51   [HELP] MySQL Error
Reply With Quote #1

Hey everyone.

Today, trying to learn some MySQL Syntax on SourcePawn, i got this error:
Code:
[LEARN] Cannot connect to MySQL Server: [1045]: Access denied for user 'tugaarm1_learnsqluser'@'185.113.141.5' (using password: YES)
Database Config (just for testing so, just IP will be hide, other info will be shown):
Code:
"Learning"
	{
		"driver"			"default"
		"host"				"XXX.XX.XX.XXX"
		"database"			"tugaarm1_learnsql"
		"user"				"tugaarm1_learnsqluser"
		"pass"				"]Ddma0IW=b2E"
		//"timeout"			"0"
		//"port"			"0"
	}
This user was set to ALL PRIVELIGIES, but I don't know why I got the error above... Down, there is also a link so you can see the image of the priveligies of the user on the database.
http://prntscr.com/rsgv3o

And also the tables are created! The table is named as datacenter and it was 2 variables: name with VARCHAR 32 and phrase with VARCHAR 32.

Source code of the plugin:
PHP Code:
#pragma semicolon 1

#define DEBUG

#define PLUGIN_AUTHOR "SpirT"
#define PLUGIN_VERSION "1.0"

#include <sourcemod>
#include <sdktools>

Database DB;
char Error[256];

#pragma newdecls required

public Plugin myinfo 
{
    
name "[SpirT] MySQL Learning",
    
author PLUGIN_AUTHOR,
    
description "",
    
version PLUGIN_VERSION,
    
url ""
};

public 
void OnPluginStart()
{
    
DB SQL_Connect("Learning"trueErrorsizeof(Error));
    
    if(
DB == null)
    {
        
PrintToServer("[LEARN] Cannot connect to MySQL Server: %s"Error);
        
CloseHandle(DB);
    }
    else
    {
        
PrintToServer("[LEARN] Connection Successful");
    }
    
    
RegAdminCmd("sm_sql"Command_SqlADMFLAG_ROOT"");
    
RegAdminCmd("sm_sqltable"Command_SqlTableADMFLAG_ROOT"");
}

public 
Action Command_Sql(int clientint args)
{
    
//sm_sql name something
    
if(args 1)
    {
        
ReplyToCommand(client"[LEARN] Please type a name.");
        return 
Plugin_Handled;
    }
    if(
args 2)
    {
        
ReplyToCommand(client"[LEARN] Please type something.");
        return 
Plugin_Handled;
    }
    
    
char arg1[32];
    
char arg2[40];
    
GetCmdArg(1arg1sizeof(arg1));
    
GetCmdArg(2arg2sizeof(arg2));
    
    
int target FindTarget(clientarg1truefalse);
    
    if(
target == -1)
    {
        
ReplyToCommand(client"[LEARN] Cannot target player.");
        return 
Plugin_Handled;
    }
    
    
char name[32];
    
GetClientName(targetnamesizeof(name));
    
    
char squery[256];
    
Format(squerysizeof(squery), "INSERT INTO datacenter (name, phrase) VALUES ('%s', '%s')"namearg2);
    
    
DBResultSet query SQL_Query(DBsquery);
    
    if(
query != INVALID_HANDLE)
    {
        
ReplyToCommand(client"[LEARN] Phrase '%s' was added to %s"arg2name);
    }
    else
    {
        
ReplyToCommand(client"[LEARN] Unable to set phrase to client");
        
SQL_GetError(DBErrorsizeof(Error));
        
ReplyToCommand(client"[LEARN] MySQL ERROR: %s"Error);
    }
    return 
Plugin_Handled;
}

public 
Action Command_SqlTable(int clientint args)
{
    
char squery[256];
    
Format(squerysizeof(squery), "CREATE TABLE IF NOT EXISTS sm_learningsql (testingstring varchar(32) NOT NULL, PRIMARY KEY (testingstring))");
    
    
DBResultSet query SQL_Query(DBsquery);
    
    if(
query != INVALID_HANDLE)
    {
        
ReplyToCommand(client"[LEARN] Table created successfully");
    }
    else
    {
        
ReplyToCommand(client"[LEARN] Unable to create table");
        
SQL_GetError(DBErrorsizeof(Error));
        
ReplyToCommand(client"[LEARN] MySQL ERROR: %s"Error);
    }
    
    return 
Plugin_Handled;

Any solution for it?

Best Regards,

SpirT.
__________________

Last edited by SpirT; 04-03-2020 at 16:09. Reason: Issue solved
SpirT is offline
8guawong
AlliedModders Donor
Join Date: Dec 2013
Location: BlackMarke7
Old 04-03-2020 , 15:25   Re: [HELP] MySQL Error
Reply With Quote #2

You probably forgot to allow the ip 185.113.141.5
__________________
8guawong is offline
SpirT
Senior Member
Join Date: Sep 2018
Location: Portugal
Old 04-03-2020 , 15:58   Re: [HELP] MySQL Error
Reply With Quote #3

Quote:
Originally Posted by 8guawong View Post
You probably forgot to allow the ip 185.113.141.5
How do I do it? I have cPanel

EDIT: Found how to add the IP and I added to the allowed servers. I am going to try and reply again with the result
__________________

Last edited by SpirT; 04-03-2020 at 15:59.
SpirT is offline
8guawong
AlliedModders Donor
Join Date: Dec 2013
Location: BlackMarke7
Old 04-03-2020 , 15:59   Re: [HELP] MySQL Error
Reply With Quote #4

https://manage.accuwebhosting.com/kn...HM-Server.html
__________________
8guawong is offline
SpirT
Senior Member
Join Date: Sep 2018
Location: Portugal
Old 04-03-2020 , 16:09   Re: [HELP] MySQL Error
Reply With Quote #5

Quote:
Originally Posted by 8guawong View Post
Worked! Thank you!
__________________
SpirT is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 13:27.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode