[Ajuda] Conexгo com banco de dados
#1

Boa tarde povo , estou tentando aprender mysql mas nгo consegui nem conectar o servidor com o banco de dados.Estou usando isso que achei aqui no forum mesmo:

PHP код:

#define Host      "localhost" 
#define Usuario   "root" 
#define Database  "samp" 
#define Senha     ""  
new Conexao;
Conexao mysql_connect(HostUsuarioDatabaseSenha);
if(
mysql_errno(Conexao) != 0
    {
        print(
"Falha na conexгo ao banco de dados Mysql");
          } else {
          print(
"Conexгo ao banco de dado Mysql efetuada com sucesso");
    } 
e da falha na conexгo , se alguem puder me dizer o porque desse erro ficarei grato :/
Reply
#2

PHP код:
#define Host      "localhost" 
#define Usuario   "root" 
#define Database  "samp" 
#define Senha     ""  
new Conexao;
Conexao mysql_connect(HostUsuarioDatabaseSenha);
if(
mysql_errno(Conexao) != 0)
    return print(
"Falha na conexгo ao banco de dados Mysql");
else
    print(
"Conexгo ao banco de dado Mysql efetuada com sucesso"); 
Vocк estб usando no seu PC, tem instalado algum server apache/mysql, estб iniciado o servidor apache/mysql?

os dados estгo correto
Код:
#define Host      "localhost" 
#define Usuario   "root" 
#define Database  "samp" 
#define Senha     ""
Reply
#3

Entгo eu estou usando o wampserver o servidor estб online
Reply
#4

mostre o que tem no mysql-log !
Reply
#5

O phpmyadmin funciona normalmente? O banco de dados tб hospedado na mesma mбquina que o servidor ou й remoto? Tenta trocar o "localhost" por "127.0.0.1", se nгo me engano o mysql plugin tem um problema com isso.
Reply
#6

2016-09-26T14:48:30.785866Z 0 [Warning] InnoDB: Resizing redo log from 2*3072 to 2*320 pages, LSN=2526311
2016-09-26T14:48:31.082266Z 0 [Warning] InnoDB: Starting to delete and rewrite log files.
2016-09-26T14:48:32.477669Z 0 [Warning] InnoDB: New log files created, LSN=2526311
Reply
#7

Quote:
Originally Posted by matanza87
Посмотреть сообщение
2016-09-26T14:48:30.785866Z 0 [Warning] InnoDB: Resizing redo log from 2*3072 to 2*320 pages, LSN=2526311
2016-09-26T14:48:31.082266Z 0 [Warning] InnoDB: Starting to delete and rewrite log files.
2016-09-26T14:48:32.477669Z 0 [Warning] InnoDB: New log files created, LSN=2526311
mysql log da pasta do seu servidor samp-server!
Reply
#8

Foi mal kk ta ai:



[13:09:35] >> mysql_connect(localhost, root, Samp, ******) on port 3306
[13:09:35] CMySQLHandler::CMySQLHandler() - constructor called.
[13:09:35] CMySQLHandler::CMySQLHandler() - Connecting to "localhost" | DB: "Samp" | Username: "root"
[13:09:35] CMySQLHandler::Connect() - Connection was successful.
[13:09:35] CMySQLHandler::Connect() - Auto-Reconnect has been enabled.
[13:09:35] >> mysql_ping( Connection handle: 1 )
[13:09:35] CMySQLHandler::Ping() - Connection is still alive.
[13:09:35] >> mysql_query_callback( Connection handle: 1 )
[13:09:35] Passing query CREATE TABLE IF NOT EXISTS 'Jogadores'('RG' int auto_increment primary key,'Nome' varchar(25) not null,'Senha' varchar(10) not null,'Level' int,'Sexo' varchar(10), 'Dinheiro' int, 'Skin' int, 'Matou' int, 'Morreu' int,'PosX' float ,'PosY' float ,'PosZ' float ,'Arma1' int , 'Arma2' int ,'Arma3' int , 'Arma4' int , 'Arma5' int , 'Arma6' int,'Balas1' int, 'Balas2' int, 'Balas3'int, 'Balas4'int, 'Balas5' int , 'Balas6' int)) |
[13:09:35] CMySQLHandler::ProcessQueryThread() - Error will be triggered to OnQueryError()
[13:09:35] OnQueryError() - Called.
[13:20:58] >> mysql_connect(localhost, root, Samp, ******) on port 3306
[13:20:58] CMySQLHandler::CMySQLHandler() - constructor called.
[13:20:58] CMySQLHandler::CMySQLHandler() - Connecting to "localhost" | DB: "Samp" | Username: "root"
[13:20:58] CMySQLHandler::Connect() - Connection was successful.
[13:20:58] CMySQLHandler::Connect() - Auto-Reconnect has been enabled.
[13:20:58] >> mysql_query_callback( Connection handle: 1 )
[13:20:58] >> mysql_errno( Connection handle: 1 )
[13:20:58] Passing query CREATE TABLE IF NOT EXISTS 'Jogadores'('RG' int auto_increment primary key,'Nome' varchar(25) not null,'Senha' varchar(10) not null,'Level' int,'Sexo' varchar(10), 'Dinheiro' int, 'Skin' int, 'Matou' int, 'Morreu' int,'PosX' float ,'PosY' float ,'PosZ' float ,'Arma1' int , 'Arma2' int ,'Arma3' int , 'Arma4' int , 'Arma5' int , 'Arma6' int,'Balas1' int, 'Balas2' int, 'Balas3'int, 'Balas4'int, 'Balas5' int , 'Balas6' int)) |
[13:20:58] CMySQLHandler::ProcessQueryThread() - Error will be triggered to OnQueryError()
[13:20:58] OnQueryError() - Called.
[13:21:06] >> mysql_connect(localhost, root, Samp, ******) on port 3306
[13:21:06] CMySQLHandler::CMySQLHandler() - constructor called.
[13:21:06] CMySQLHandler::CMySQLHandler() - Connecting to "localhost" | DB: "Samp" | Username: "root"
[13:21:06] CMySQLHandler::Connect() - Connection was successful.
[13:21:06] CMySQLHandler::Connect() - Auto-Reconnect has been enabled.
[13:21:06] >> mysql_query_callback( Connection handle: 1 )
[13:21:06] >> mysql_errno( Connection handle: 1 )
[13:21:06] Passing query CREATE TABLE IF NOT EXISTS 'Jogadores'('RG' int auto_increment primary key,'Nome' varchar(25) not null,'Senha' varchar(10) not null,'Level' int,'Sexo' varchar(10), 'Dinheiro' int, 'Skin' int, 'Matou' int, 'Morreu' int,'PosX' float ,'PosY' float ,'PosZ' float ,'Arma1' int , 'Arma2' int ,'Arma3' int , 'Arma4' int , 'Arma5' int , 'Arma6' int,'Balas1' int, 'Balas2' int, 'Balas3'int, 'Balas4'int, 'Balas5' int , 'Balas6' int)) |
[13:21:06] CMySQLHandler::ProcessQueryThread() - Error will be triggered to OnQueryError()
[13:21:06] OnQueryError() - Called.
[13:23:58] >> mysql_connect(localhost, root, Samp, ******) on port 3306
[13:23:58] CMySQLHandler::CMySQLHandler() - constructor called.
[13:23:58] CMySQLHandler::CMySQLHandler() - Connecting to "localhost" | DB: "Samp" | Username: "root"
[13:23:58] CMySQLHandler::Connect() - Unknown MySQL server host 'localhost' (11001) (Error ID: 2005)
[13:23:58] >> mysql_query_callback( Connection handle: 1 )
[13:23:58] >> mysql_errno( Connection handle: 1 )
[12:06:54] >> mysql_connect(localhost, root, Samp, ******) on port 3306
[12:06:54] CMySQLHandler::CMySQLHandler() - constructor called.
[12:06:54] CMySQLHandler::CMySQLHandler() - Connecting to "localhost" | DB: "Samp" | Username: "root"
[12:06:54] CMySQLHandler::Connect() - Unknown database 'samp' (Error ID: 1049)
[12:06:54] >> mysql_query_callback( Connection handle: 1 )
[12:06:54] >> mysql_errno( Connection handle: 1 )
[12:15:58] >> mysql_connect(192.168.0.104, root, Samp, ******) on port 3306
[12:15:58] CMySQLHandler::CMySQLHandler() - constructor called.
[12:15:58] CMySQLHandler::CMySQLHandler() - Connecting to "192.168.0.104" | DB: "Samp" | Username: "root"
[12:15:58] CMySQLHandler::Connect() - Host 'Carol-PC' is not allowed to connect to this MySQL server (Error ID: 1130)
[12:15:58] >> mysql_query_callback( Connection handle: 1 )
[12:15:58] >> mysql_errno( Connection handle: 1 )
[12:20:56] >> mysql_connect(192.168.0.104, root, Samp, ******) on port 3306
[12:20:56] CMySQLHandler::CMySQLHandler() - constructor called.
[12:20:56] CMySQLHandler::CMySQLHandler() - Connecting to "192.168.0.104" | DB: "Samp" | Username: "root"
[12:20:56] CMySQLHandler::Connect() - Host 'Carol-PC' is not allowed to connect to this MySQL server (Error ID: 1130)
[12:20:56] >> mysql_query_callback( Connection handle: 1 )
[12:20:56] >> mysql_errno( Connection handle: 1 )
[12:25:29] >> mysql_connect(192.168.0.104, root, Samp, ******) on port 3306
[12:25:29] CMySQLHandler::CMySQLHandler() - constructor called.
[12:25:29] CMySQLHandler::CMySQLHandler() - Connecting to "192.168.0.104" | DB: "Samp" | Username: "root"
[12:25:29] CMySQLHandler::Connect() - Host 'Carol-PC' is not allowed to connect to this MySQL server (Error ID: 1130)
[12:25:29] >> mysql_query_callback( Connection handle: 1 )
[12:25:29] >> mysql_errno( Connection handle: 1 )
[12:26:24] >> mysql_connect(localhost3306, root, samp, ******) on port 3306
[12:26:24] CMySQLHandler::CMySQLHandler() - constructor called.
[12:26:24] CMySQLHandler::CMySQLHandler() - Connecting to "localhost3306" | DB: "samp" | Username: "root"
[12:26:26] CMySQLHandler::Connect() - Unknown MySQL server host 'localhost3306' (11004) (Error ID: 2005)
[12:26:26] >> mysql_query_callback( Connection handle: 1 )
[12:26:26] >> mysql_errno( Connection handle: 1 )
[12:56:38] >> mysql_connect(192.168.0.104, root, samp, ******) on port 3306
[12:56:38] CMySQLHandler::CMySQLHandler() - constructor called.
[12:56:38] CMySQLHandler::CMySQLHandler() - Connecting to "192.168.0.104" | DB: "samp" | Username: "root"
[12:56:38] CMySQLHandler::Connect() - Host 'Carol-PC' is not allowed to connect to this MySQL server (Error ID: 1130)
[12:56:38] >> mysql_query_callback( Connection handle: 1 )
[12:56:38] >> mysql_errno( Connection handle: 1 )
[13:32:45] >> mysql_connect(127.0.0.1, root, samp, ******) on port 3306
[13:32:45] CMySQLHandler::CMySQLHandler() - constructor called.
[13:32:45] CMySQLHandler::CMySQLHandler() - Connecting to "127.0.0.1" | DB: "samp" | Username: "root"
[13:32:45] CMySQLHandler::Connect() - Connection was successful.
[13:32:45] CMySQLHandler::Connect() - Auto-Reconnect has been enabled.
[13:32:45] >> mysql_query_callback( Connection handle: 1 )
[13:32:45] >> mysql_errno( Connection handle: 1 )
[13:32:45] Passing query CREATE TABLE IF NOT EXISTS 'Jogadores'('RG' int auto_increment primary key,'Nome' varchar(25) not null,'Senha' varchar(10) not null,'Level' int,'Sexo' varchar(10), 'Dinheiro' int, 'Skin' int, 'Matou' int, 'Morreu' int,'PosX' float ,'PosY' float ,'PosZ' float ,'Arma1' int , 'Arma2' int ,'Arma3' int , 'Arma4' int , 'Arma5' int , 'Arma6' int,'Balas1' int, 'Balas2' int, 'Balas3'int, 'Balas4'int, 'Balas5' int , 'Balas6' int)) |
[13:32:45] CMySQLHandler::ProcessQueryThread() - Error will be triggered to OnQueryError()
[13:32:45] OnQueryError() - Called.
Reply
#9

Quote:

Passing query CREATE TABLE IF NOT EXISTS 'Jogadores'('RG' int auto_increment primary key,'Nome' varchar(25) not null,'Senha' varchar(10) not null,'Level' int,'Sexo' varchar(10), 'Dinheiro' int, 'Skin' int, 'Matou' int, 'Morreu' int,'PosX' float ,'PosY' float ,'PosZ' float ,'Arma1' int , 'Arma2' int ,'Arma3' int , 'Arma4' int , 'Arma5' int , 'Arma6' int,'Balas1' int, 'Balas2' int, 'Balas3'int, 'Balas4'int, 'Balas5' int , 'Balas6' int)) |

Sua conexгo tб crashando aн, aumenta o tamanho dessa string no seu gamemode.
Reply
#10

eu tirei esse cуdigo de criaзгo de tabela e ainda aparece falha na conexгo mas no mysql-log ta assim:


[13:41:56] >> mysql_connect(localhost, root, samp, ******) on port 3306
[13:41:56] CMySQLHandler::CMySQLHandler() - constructor called.
[13:41:56] CMySQLHandler::CMySQLHandler() - Connecting to "localhost" | DB: "samp" | Username: "root"
[13:41:56] CMySQLHandler::Connect() - Connection was successful.
[13:41:57] CMySQLHandler::Connect() - Auto-Reconnect has been enabled.
[13:41:57] >> mysql_errno( Connection handle: 1 )
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)