I2sync
17/05/2007, 21:07
#include <windows.h>
#include <iostream>
#include <mysql/mysql.h>
using namespace std;
int main()
{
//connection params
char *host = "127.0.0.1";
char *user = "root";
char *pass = "123456";
char *db = "test";
//sock
MYSQL *sock;
sock = mysql_init(0);
if (sock) cout << "sock handle ok!" << endl;
else {
cout << "sock handle failed!" << endl;
return EXIT_FAILURE;
}
//connection
if (mysql_real_connect(sock, host, user, pass, db, 0, NULL, 0))
cout << "connection ok!" << endl;
else {
cout << "connection failed!" << endl;
return EXIT_FAILURE;
}
//wait for posibility to check system/mysql sockets
system("PAUSE");
//closing connection
mysql_close(sock);
return EXIT_SUCCESS;
}
mysql neden bağlanmıyor...windows kullanıcısıyım..
sock handle ok!
connection failed!
cevabını veriyor..
#include <iostream>
#include <mysql/mysql.h>
using namespace std;
int main()
{
//connection params
char *host = "127.0.0.1";
char *user = "root";
char *pass = "123456";
char *db = "test";
//sock
MYSQL *sock;
sock = mysql_init(0);
if (sock) cout << "sock handle ok!" << endl;
else {
cout << "sock handle failed!" << endl;
return EXIT_FAILURE;
}
//connection
if (mysql_real_connect(sock, host, user, pass, db, 0, NULL, 0))
cout << "connection ok!" << endl;
else {
cout << "connection failed!" << endl;
return EXIT_FAILURE;
}
//wait for posibility to check system/mysql sockets
system("PAUSE");
//closing connection
mysql_close(sock);
return EXIT_SUCCESS;
}
mysql neden bağlanmıyor...windows kullanıcısıyım..
sock handle ok!
connection failed!
cevabını veriyor..