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", true, Error, sizeof(Error));
if(DB == null)
{
PrintToServer("[LEARN] Cannot connect to MySQL Server: %s", Error);
CloseHandle(DB);
}
else
{
PrintToServer("[LEARN] Connection Successful");
}
RegAdminCmd("sm_sql", Command_Sql, ADMFLAG_ROOT, "");
RegAdminCmd("sm_sqltable", Command_SqlTable, ADMFLAG_ROOT, "");
}
public Action Command_Sql(int client, int 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(1, arg1, sizeof(arg1));
GetCmdArg(2, arg2, sizeof(arg2));
int target = FindTarget(client, arg1, true, false);
if(target == -1)
{
ReplyToCommand(client, "[LEARN] Cannot target player.");
return Plugin_Handled;
}
char name[32];
GetClientName(target, name, sizeof(name));
char squery[256];
Format(squery, sizeof(squery), "INSERT INTO datacenter (name, phrase) VALUES ('%s', '%s')", name, arg2);
DBResultSet query = SQL_Query(DB, squery);
if(query != INVALID_HANDLE)
{
ReplyToCommand(client, "[LEARN] Phrase '%s' was added to %s", arg2, name);
}
else
{
ReplyToCommand(client, "[LEARN] Unable to set phrase to client");
SQL_GetError(DB, Error, sizeof(Error));
ReplyToCommand(client, "[LEARN] MySQL ERROR: %s", Error);
}
return Plugin_Handled;
}
public Action Command_SqlTable(int client, int args)
{
char squery[256];
Format(squery, sizeof(squery), "CREATE TABLE IF NOT EXISTS sm_learningsql (testingstring varchar(32) NOT NULL, PRIMARY KEY (testingstring))");
DBResultSet query = SQL_Query(DB, squery);
if(query != INVALID_HANDLE)
{
ReplyToCommand(client, "[LEARN] Table created successfully");
}
else
{
ReplyToCommand(client, "[LEARN] Unable to create table");
SQL_GetError(DB, Error, sizeof(Error));
ReplyToCommand(client, "[LEARN] MySQL ERROR: %s", Error);
}
return Plugin_Handled;
}
Any solution for it?
Best Regards,
SpirT.
__________________