MySQL desde Linux

MySQL desde Linux

Postby softruz » Mon Dec 14, 2009 9:34 am

Muy buenas, ya he conseguido MySQL desde linux yo he usado openSuse v.11.1 y v.11.2, si alguien quiere configurarlo y el código fuente, que me comunique.

Un Saludo.
softruz
 
Posts: 485
Joined: Fri Feb 09, 2007 10:34 am

Re: MySQL desde Linux

Postby Antonio Linares » Mon Dec 14, 2009 9:31 pm

Juan,

Te agradecemos cualquier ejemplo y explicaciones que quieras proporcionarnos a todos aqui en el foro, gracias :-)
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 41289
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: MySQL desde Linux

Postby softruz » Wed Dec 16, 2009 8:33 am

Muy buenas, aunque yo estoy utilizando la distrubicion openSuse 11.2 se podría hacer con cualquiera, lo que debemos que hacer es instalar los paquetes necesarios, yo utilizo el yast2 ,
1º Los paquetes son:

libmysqlclient-devel
libmysqlclient16
mysql
mysql-gui-tools

2º Antetodo, yo he utilizado la carpeta samples para construir el ejemplo. Para la configuracion del buildx.sh sería esta para openSuse 11.2 (Según la distribución o version de ella puede cambiar la configuración), si teneis una distribución o versión diferente tenéis que utilizar:

mysql_config --libs // Para enlazar las librerías
mysql_config --cflags // Para enlazar los includes

así quedaría:
INCLUDES
-I/usr/include/mysql -fomit-frame-pointer -fmessage-length=0 -D_FORTIFY_SOURCE=2 -fstack-protector -funwind-tables -fasynchronous-unwind-tables -g -DPIC -fPIC -DUNDEF_HAVE_INITGROUPS -fno-strict-aliasing -DUNIV_LINUX

LIBRERÍA
-L/usr/lib/mysql -lmysqlclient -lz -lcrypt -lnsl -lm -L/usr/lib -L/usr/lib64 -lssl -lcrypto

3º El código es el siguiente:

#include "FiveLinux.ch"

function Main()

local oDlg

DEFINE DIALOG oDlg TITLE "Testing popup menus"

@ 2, 2 SAY "right click" OF oDlg

ACTIVATE DIALOG oDlg CENTERED ;
VALID MsgYesNo( "Want to end ?" ) ;
ON RIGHT CLICK ShowPopup( oDlg )

return nil

function ShowPopup( oDlg )

local oPopup

MENU oPopup POPUP
MENUITEM "One" RESOURCE "gtk-new" ACTION MySQL_CONNECT()
MENUITEM "Two" RESOURCE "gtk-save" ACTION MsgInfo( "save" )
MENUITEM "Three" RESOURCE "gtk-quit" ACTION MsgInfo( "quit" )
ENDMENU

ACTIVATE POPUP oPopup OF oDlg

return nil

#pragma BEGINDUMP


#include <hbapi.h>
#include <mysql.h>

HB_FUNC( MYSQL_CONNECT )
{
MYSQL *conn;
MYSQL_RES *res;
MYSQL_ROW row;

char *server = "192.168.0.254";
char *user = "root";
char *password = "cdi";
char *database = "cdibussev";

conn = mysql_init(NULL);

/* Connect to database */
if (!mysql_real_connect(conn, server, user, password, database, 0, NULL, 0))
{
fprintf(stderr, "%s\n", mysql_error(conn));
exit(1);
}

/* send SQL query */
if (mysql_query(conn, "show tables"))
{
fprintf(stderr, "%s\n", mysql_error(conn));
exit(1);
}

res = mysql_use_result(conn);

/* output table name */
printf("MySQL Tables in mysql database:\n");
while ((row = mysql_fetch_row(res)) != NULL)
printf("%s \n", row[0]);

/* close connection */
mysql_free_result(res);
mysql_close(conn);
}

#pragma ENDDUMP

Si tenéis alguna duda no dudeis en postearla.

Un Saludo.
softruz
 
Posts: 485
Joined: Fri Feb 09, 2007 10:34 am

Re: MySQL desde Linux

Postby Antonio Linares » Wed Dec 16, 2009 9:03 am

Juan,

Gracias! :-)
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 41289
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: MySQL desde Linux

Postby ruben Dario » Thu Feb 17, 2011 6:53 pm

softruz wrote:Muy buenas, aunque yo estoy utilizando la distrubicion openSuse 11.2 se podría hacer con cualquiera, lo que debemos que hacer es instalar los paquetes necesarios, yo utilizo el yast2 ,
1º Los paquetes son:

libmysqlclient-devel
libmysqlclient16
mysql
mysql-gui-tools

2º Antetodo, yo he utilizado la carpeta samples para construir el ejemplo. Para la configuracion del buildx.sh sería esta para openSuse 11.2 (Según la distribución o version de ella puede cambiar la configuración), si teneis una distribución o versión diferente tenéis que utilizar:

mysql_config --libs // Para enlazar las librerías
mysql_config --cflags // Para enlazar los includes

así quedaría:
INCLUDES
-I/usr/include/mysql -fomit-frame-pointer -fmessage-length=0 -D_FORTIFY_SOURCE=2 -fstack-protector -funwind-tables -fasynchronous-unwind-tables -g -DPIC -fPIC -DUNDEF_HAVE_INITGROUPS -fno-strict-aliasing -DUNIV_LINUX

LIBRERÍA
-L/usr/lib/mysql -lmysqlclient -lz -lcrypt -lnsl -lm -L/usr/lib -L/usr/lib64 -lssl -lcrypto

3º El código es el siguiente:

#include "FiveLinux.ch"

function Main()

local oDlg

DEFINE DIALOG oDlg TITLE "Testing popup menus"

@ 2, 2 SAY "right click" OF oDlg

ACTIVATE DIALOG oDlg CENTERED ;
VALID MsgYesNo( "Want to end ?" ) ;
ON RIGHT CLICK ShowPopup( oDlg )

return nil

function ShowPopup( oDlg )

local oPopup

MENU oPopup POPUP
MENUITEM "One" RESOURCE "gtk-new" ACTION MySQL_CONNECT()
MENUITEM "Two" RESOURCE "gtk-save" ACTION MsgInfo( "save" )
MENUITEM "Three" RESOURCE "gtk-quit" ACTION MsgInfo( "quit" )
ENDMENU

ACTIVATE POPUP oPopup OF oDlg

return nil

#pragma BEGINDUMP


#include <hbapi.h>
#include <mysql.h>

HB_FUNC( MYSQL_CONNECT )
{
MYSQL *conn;
MYSQL_RES *res;
MYSQL_ROW row;

char *server = "192.168.0.254";
char *user = "root";
char *password = "cdi";
char *database = "cdibussev";

conn = mysql_init(NULL);

/* Connect to database */
if (!mysql_real_connect(conn, server, user, password, database, 0, NULL, 0))
{
fprintf(stderr, "%s\n", mysql_error(conn));
exit(1);
}

/* send SQL query */
if (mysql_query(conn, "show tables"))
{
fprintf(stderr, "%s\n", mysql_error(conn));
exit(1);
}

res = mysql_use_result(conn);

/* output table name */
printf("MySQL Tables in mysql database:\n");
while ((row = mysql_fetch_row(res)) != NULL)
printf("%s \n", row[0]);

/* close connection */
mysql_free_result(res);
mysql_close(conn);
}

#pragma ENDDUMP

Si tenéis alguna duda no dudeis en postearla.

Un Saludo.
Ruben Dario Gonzalez
Cali-Colombia
rubendariogd@hotmail.com - rubendariogd@gmail.com
User avatar
ruben Dario
 
Posts: 1061
Joined: Thu Sep 27, 2007 3:47 pm
Location: Colombia

Prueba MySQL desde Linux me falta mysql.h

Postby ruben Dario » Fri Feb 18, 2011 1:03 pm

Estoy haciendo la prueba y me falta #include <mysql.h>

Anexo codigo que me facilitaron en el forum
Code: Select all  Expand view


#include "FiveLinux.ch"

function Main()

local oDlg

DEFINE DIALOG oDlg TITLE "Testing popup menus"

@ 2, 2 SAY "right click" OF oDlg

ACTIVATE DIALOG oDlg CENTERED ;
VALID MsgYesNo( "Want to end ?" ) ;
ON RIGHT CLICK ShowPopup( oDlg )

return nil

function ShowPopup( oDlg )

local oPopup

MENU oPopup POPUP
MENUITEM "One" RESOURCE "gtk-new" ACTION MySQL_CONNECT()
MENUITEM "Two" RESOURCE "gtk-save" ACTION MsgInfo( "save" )
MENUITEM "Three" RESOURCE "gtk-quit" ACTION MsgInfo( "quit" )
ENDMENU

ACTIVATE POPUP oPopup OF oDlg

return nil

#pragma BEGINDUMP


#include <hbapi.h>
#include <mysql.h>

HB_FUNC( MYSQL_CONNECT )
{
MYSQL *conn;
MYSQL_RES *res;
MYSQL_ROW row;

char *server = "192.168.0.254";
char *user = "root";
char *password = "cdi";
char *database = "cdibussev";

conn = mysql_init(NULL);

/* Connect to database */
if (!mysql_real_connect(conn, server, user, password, database, 0, NULL, 0))
{
fprintf(stderr, "%s\n", mysql_error(conn));
exit(1);
}

/* send SQL query */
if (mysql_query(conn, "show tables"))
{
fprintf(stderr, "%s\n", mysql_error(conn));
exit(1);
}

res = mysql_use_result(conn);

/* output table name */
printf("MySQL Tables in mysql database:\n");
while ((row = mysql_fetch_row(res)) != NULL)
printf("%s \n", row[0]);

/* close connection */
mysql_free_result(res);
mysql_close(conn);
}

#pragma ENDDUMP



 

Seria posible me puedes facilitar el buildx.sh para ver el codigo.
Gracias
Ruben Dario Gonzalez
Cali-Colombia
rubendariogd@hotmail.com - rubendariogd@gmail.com
User avatar
ruben Dario
 
Posts: 1061
Joined: Thu Sep 27, 2007 3:47 pm
Location: Colombia

Re: MySQL desde Linux

Postby Daniel Garcia-Gil » Fri Feb 18, 2011 1:37 pm

Ruben

Enconstraste algun problema con dolphin?

te ahorrarias mucho trabajo, pues de la forma como lo estas haciendo haras todo el proceso "a mano"
aqui en el foro puedes hacer tus preguntas sobre dolphin sin problema alguno,
no hay documentacion de la clase como tal, pues no he tenido tiempo de hacerla, pero los metodos estan bien descritos, viendo un poco la clase los ejemplos, seguro la curva de aprendizaje sera bastante rapida

http://forums.fivetechsupport.com/viewtopic.php?p=110841#p110841
User avatar
Daniel Garcia-Gil
 
Posts: 2365
Joined: Wed Nov 02, 2005 11:46 pm
Location: Isla de Margarita

Re: MySQL desde Linux

Postby ruben Dario » Fri Feb 18, 2011 10:32 pm

Daniel Garcia-Gil wrote:Ruben

Enconstraste algun problema con dolphin?

te ahorrarias mucho trabajo, pues de la forma como lo estas haciendo haras todo el proceso "a mano"
aqui en el foro puedes hacer tus preguntas sobre dolphin sin problema alguno,
no hay documentacion de la clase como tal, pues no he tenido tiempo de hacerla, pero los metodos estan bien descritos, viendo un poco la clase los ejemplos, seguro la curva de aprendizaje sera bastante rapida

http://forums.fivetechsupport.com/viewtopic.php?p=110841#p110841



Daniel.
Voy a hacer la prueba este fin de semana, y te comento el lunes.
Te pregunto el dolphin solo funciona para linux.

Gracias, Que tengas un buen fin de semana
Ruben Dario Gonzalez
Cali-Colombia
rubendariogd@hotmail.com - rubendariogd@gmail.com
User avatar
ruben Dario
 
Posts: 1061
Joined: Thu Sep 27, 2007 3:47 pm
Location: Colombia

Re: MySQL desde Linux

Postby Daniel Garcia-Gil » Fri Feb 18, 2011 10:43 pm

Ruben

Funciona para linux, window 32 y 64, Mac (OSX)
User avatar
Daniel Garcia-Gil
 
Posts: 2365
Joined: Wed Nov 02, 2005 11:46 pm
Location: Isla de Margarita

Re: MySQL desde Linux

Postby ruben Dario » Mon Feb 21, 2011 9:38 pm

Daniel Garcia-Gil wrote:Ruben

Funciona para linux, window 32 y 64, Mac (OSX)


Saludos
Daniel, he tenido problema en crear la libreria.
Estoy hacieno la prueba con windows para despues pasar a linux.

Ejecuto el archivo mtdolpx.bat
Pero genera error , segun parece como esta encadenando la libreria libmysql.lib , creo que es esto.
///
Code: Select all  Expand view

mtdolpx.bat

K:\bcc582\bin\make -ftdolp.mak HPATH=\XHARBOUR BCCPATH=\BCC582 LIBNAME=dolphinx OBJS=objx HARBOUR=__XHARBOUR__

el tdolp.mak

OBJPRG  = .\$(OBJS)
OBJC    = .\objc
INCLUDE = .\include
LIBNAME = $(LIBNAME)

.path.PRG = .\source\prg
.path.OBJ = $(OBJPRG)
.path.CH  = $(INCLUDE)
.path.C   = .\source\c
.path.LIB = .\lib

PRG =        \
TDOLPSRV.PRG \
TDOLPQRY.PRG

C =                   \
FUNCTION.C              

PROJECT    : $(LIBNAME).lib

$(LIBNAME).lib   : $(PRG:.PRG=.OBJ) $(C:.C=.OBJ)

.PRG.OBJ:
   $(HPATH)\bin\harbour $<  /N /W /w /es2 /O$(OBJPRG)\ /I$(INCLUDE);$(HPATH)\include;$(USERINC) > comp.log
   $(BCCPATH)\bin\bcc32  -c -tWM -I$(HPATH)\include -o$(OBJPRG)\$& $(OBJPRG)\$&.c
   $(BCCPATH)\bin\TLib .\lib\$(LIBNAME).lib -+$(OBJPRG)\$&.obj /0 /P32,,

.C.OBJ:
  echo -c -tWM -D$(HARBOUR) > tmp
  echo -I$(HPATH)\include;$(INCLUDE);$(USERINC) >> tmp
   $(BCCPATH)\bin\bcc32 -o$(OBJC)\$& @tmp $<
   $(BCCPATH)\bin\TLib .\lib\$(LIBNAME).lib -+$(OBJC)\$&.obj /0 /P32,,


Error Que Genera

xHarbour Compiler build 1.2.1 (SimpLex) (Rev. 6741)
Copyright 1999-2010, http://www.xharbour.org http://www.harbour-project.org/
Compiling '.\source\prg\TDOLPSRV.PRG'...


.\source\prg\TDOLPSRV.PRG(465) Warning W0001  Ambiguous reference: 'ERR_CANNOTCREATEBKFILE'

.\source\prg\TDOLPSRV.PRG(480) Warning W0001  Ambiguous reference: 'ERR_OPENBACKUPFILE'


.\source\prg\TDOLPSRV.PRG(566) Warning W0001  Ambiguous reference: 'ST_FILLBACKUP'


.\source\prg\TDOLPSRV.PRG(607) Warning W0001  Ambiguous reference: 'ST_FILLBACKUP'

.\source\prg\TDOLPSRV.PRG(661) Warning W0001  Ambiguous reference: 'ERR_INSUFFICIENT_MEMORY'

.\source\prg\TDOLPSRV.PRG(677) Warning W0001  Ambiguous reference: 'CR_SERVER_GONE_ERROR'


.\source\prg\TDOLPSRV.PRG(1412) Warning W0001  Ambiguous reference: 'ERR_INVALIDQUERYARRAY'

.\source\prg\TDOLPSRV.PRG(1450) Warning W0001  Ambiguous reference: 'ERR_MULTIQUERYFAULIRE'


.\source\prg\TDOLPSRV.PRG(1709) Warning W0001  Ambiguous reference: 'ERR_TABLENOEXIST'

.\source\prg\TDOLPSRV.PRG(1735) Warning W0001  Ambiguous reference: 'MAX_BLOCKSIZE'


.\source\prg\TDOLPSRV.PRG(2276) Warning W0001  Ambiguous reference: 'ERR_INVALIDHOSTSELECTION'


.\source\prg\TDOLPSRV.PRG(2319) Warning W0001  Ambiguous reference: 'ERR_INVALIDHOSTSELECTION'


0 error

No code generated
 

Code: Select all  Expand view

Si lo hafgo con verce pasa esto.
[url]http://img253.imageshack.us/i/erorconvervce.jpg/[/url]

 
Ruben Dario Gonzalez
Cali-Colombia
rubendariogd@hotmail.com - rubendariogd@gmail.com
User avatar
ruben Dario
 
Posts: 1061
Joined: Thu Sep 27, 2007 3:47 pm
Location: Colombia

Re: MySQL desde Linux

Postby Daniel Garcia-Gil » Mon Feb 21, 2011 11:46 pm

Ruben

estan mal direccionados los path de los includes...

TDolphin te ofrece los script para construir la libreria...

usa los setenv*.bat
User avatar
Daniel Garcia-Gil
 
Posts: 2365
Joined: Wed Nov 02, 2005 11:46 pm
Location: Isla de Margarita


Return to FiveLinux / FiveDroid (Android)

Who is online

Users browsing this forum: No registered users and 7 guests