how to connect infinidb with php??

13 posts / 0 new
Last post
rasel200209
rasel200209's picture
Offline
Last seen: 3 years 2 months ago
Joined: Nov 24 2009
Junior Boarder

Posts: 2

Rasel Ahmed
how to connect infinidb with php??

thanks you all for helping me.

In my server, php, mysql and apache web server are running well and i can access mysql through php script very nicely. it works fine php with mysql.
Example:
var $dbhost='localhost';
var $dbusername='ultralys_mybook';
var $dbpassword="Booker113";
$link_id=mysql_connect($this->dbhost,$this->dbusername,$this->dbpassword);

Now, you know, I have installed Infinidb in the same server. and creates databases,tables as 'root' user in infinidb.
CalpontInfiniDBConceptsGuide.pdf, here i saw very little document.

please tell me with specific sequential instructions, what should I do to connect infinidb with upon php in ther server pc with php script example.

Also, if there have any useful link with php example, please give me!!!

rasel200209
rasel200209's picture
Offline
Last seen: 3 years 2 months ago
Joined: Nov 24 2009
Junior Boarder

Posts: 2

Rasel Ahmed
Re:how to connect infinidb with php??

Now ok. no problem. Connection is ok.

melina386
melina386's picture
Offline
Last seen: 4 years 7 months ago
Joined: Dec 11 2009
Junior Boarder

Posts: 6

melina dee
Re:how to connect infinidb with php??

you can explain how you have overcome this problem.So that it may useful for someone when they are in trouble.
--------------------
[url=http://www.e-datapro.net]Data Entry India[/url]

davidhill
davidhill's picture
Offline
Last seen: 1 month 3 weeks ago
Joined: Oct 27 2009
Administrator

Posts: 595

david hill
Re:how to connect infinidb with php??

You would setup to interface with InfiniDB Mysql just like you would with the regular MySql.

jcmtnez
jcmtnez's picture
Offline
Last seen: 3 years 1 month ago
Joined: Jul 9 2011
Junior Boarder

Posts: 4

Juan Martinez
Re: how to connect infinidb with php??

I've tested the following connections in PHP with no luck:

$con1 = mysql_connect('localhost:/usr/local/Calpont/mysql/lib/mysql/mysql.sock', 'root','mypassword');

Getting the error: Can't connect to local MySQL server through socket '/usr/local/Calpont/mysql/lib/mysql/mysql.sock' (13)

and...

$con1 = mysql_connect('localhost', 'root','mypassword');

Getting the error: Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)

I'm running CentOS 5.6

I'm assuming that the database is working because in the command line I've previously excecuted:

[root@localhost ~]# /etc/init.d/infinidb start
Starting Calpont InfiniDB Database Platform: ....... DONE
Starting Calpont InfiniDB MySQL:
Starting MySQL. [ OK ]
Validate InfiniDB System Catalog:

*** Enter MySQL password: [I'VE ENTERED THE ROOT PASSWORD HERE]
Validation Succesfully Completed
Perform Functionality test:
InfiniDB Logging check: DONE
Platform Process check: DONE
MySQL Daemon check: MySQL running (4472) [ OK ]
Database check: DONE

I've also done:

[root@localhost ~]# . /usr/local/Calpont/bin/calpontAlias
[root@localhost ~]# idbmysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or g.
Your MySQL connection id is 6
Server version: 5.1.39 MySQL Community / Calpont InfiniDB Community 2.2-2 Final (COSS LA)

Type 'help;' or 'h' for help. Type 'c' to clear the current input statement.

mysql>

Please, can anyone tell what am I missing?

Thanks

rasel200209
rasel200209's picture
Offline
Last seen: 3 years 2 months ago
Joined: Nov 24 2009
Junior Boarder

Posts: 2

Rasel Ahmed
Re: how to connect infinidb with php??

try to use like..

$con1 = mysql_connect('localhost:3008', 'root','mypassword');

$con1 = mysql_connect('hostName:Port_number', 'root','mypassword');

radams
radams's picture
Offline
Last seen: 4 days 16 hours ago
Joined: Jan 3 2011
Administrator

Posts: 492

Robert Adams
Re: how to connect infinidb with php??

I believe that rasel200209 was providing an example of the command. Your install is using the normal default port of 3306.

Here is another method.

import MySQLdb

def connect_database(host,username,passwd,db,port,unix_socket):
try:
db_handle =
MySQLdb.connect(host,username,passwd,db,port,unix_socket)
print db_handle,"\n"
return db_handle
except Exception, e:
print "\n Exception occurred in connect_database() of database.py"
print e

ret=connect_database('localhost','','','',3306,'/usr/local/Ca
lpont/mysql/lib/mysql/mysql.sock')
-------

Fill in the variables in '<>' with your own info.

Thanks,

Robert
Calpont

jcmtnez
jcmtnez's picture
Offline
Last seen: 3 years 1 month ago
Joined: Jul 9 2011
Junior Boarder

Posts: 4

Juan Martinez
Re: how to connect infinidb with php??

Thanks for responding so quickly.

After adding the port 3008 to the connection, I continue getting the same error: Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2).

I ran a port scan using nmap and I don't have services listening on 3008. Below is the output of my nmap:

Quote:# nmap -T Aggressive -A -v 127.0.0.1 -p 1-65000

Starting Nmap 4.11 ( http://www.insecure.org/nmap/ ) at 2011-07-11 11:48 EDT
Initiating SYN Stealth Scan against localhost.localdomain (127.0.0.1) [65000 ports] at 11:48
Discovered open port 80/tcp on 127.0.0.1
Discovered open port 22/tcp on 127.0.0.1
Discovered open port 25/tcp on 127.0.0.1
Discovered open port 8620/tcp on 127.0.0.1
Discovered open port 8700/tcp on 127.0.0.1
Discovered open port 8614/tcp on 127.0.0.1
Discovered open port 8601/tcp on 127.0.0.1
Discovered open port 3306/tcp on 127.0.0.1
Discovered open port 8612/tcp on 127.0.0.1
Discovered open port 111/tcp on 127.0.0.1
Discovered open port 8616/tcp on 127.0.0.1
Discovered open port 834/tcp on 127.0.0.1
The SYN Stealth Scan took 1.44s to scan 65000 total ports.
Initiating service scan against 12 services on localhost.localdomain (127.0.0.1) at 11:48
Service scan Timing: About 66.67% done; ETC: 11:51 (0:00:56 remaining)
The service scan took 113.52s to scan 12 services on 1 host.
Initiating RPCGrind Scan against localhost.localdomain (127.0.0.1) at 11:50
The RPCGrind Scan took 0.00s to scan 2 ports on localhost.localdomain (127.0.0.1).
For OSScan assuming port 22 is open, 1 is closed, and neither are firewalled
For OSScan assuming port 22 is open, 1 is closed, and neither are firewalled
For OSScan assuming port 22 is open, 1 is closed, and neither are firewalled
Host localhost.localdomain (127.0.0.1) appears to be up ... good.
Interesting ports on localhost.localdomain (127.0.0.1):
Not shown: 64988 closed ports
PORT STATE SERVICE VERSION
22/tcp open ssh OpenSSH 4.3 (protocol 2.0)
25/tcp open smtp Sendmail 8.13.8/8.13.8
80/tcp open http Apache httpd 2.2.3 ((CentOS))
111/tcp open rpc
834/tcp open rpc
3306/tcp open mysql MySQL 5.1.39
8601/tcp open unknown
8612/tcp open unknown
8614/tcp open unknown
8616/tcp open unknown
8620/tcp open unknown
8700/tcp open unknown
5 services unrecognized despite returning data.

I wonder if there is something wrong with my install. I followed the instructions from http://survivalguides.wordpress.com/2011/06/03/i

jcmtnez
jcmtnez's picture
Offline
Last seen: 3 years 1 month ago
Joined: Jul 9 2011
Junior Boarder

Posts: 4

Juan Martinez
Re: how to connect infinidb with php??

Radams, thanks for helping.

Is your suggested code for a language other than PHP?

My application is in PHP language. AFAIK the closest that I can get to that in PHP would be:

ret=mysql_connect('localhost:/usr/local/Ca
lpont/mysql/lib/mysql/mysql.sock', '','');

instead of:

ret=connect_database('localhost','','','',3306,'/usr/local/Ca
lpont/mysql/lib/mysql/mysql.sock');

When I do the first I get: Could not connect: Can't connect to local MySQL server through socket '/usr/local/Calpont/mysql/lib/mysql/mysql.sock' (13)

I noticed that you suggested

Quote:import MySQLdb

though I'm not sure whether this means that there is a class by that name somewhere in the system. Could you clarify?

Could you provide a portion of PHP code that works on your system to connect PHP to InfiniDB?

Thanks.

rasel200209
rasel200209's picture
Offline
Last seen: 3 years 2 months ago
Joined: Nov 24 2009
Junior Boarder

Posts: 2

Rasel Ahmed
Re: how to connect infinidb with php??

Infinidb default port 3306. Sometimes in the same server if u install mysql, then it makes conflict. os its better, infinidb port should be changed. Anyway, you know your infinidb port. if you dont change anything, your infinidb port is in 3306.

so now to connect with mysql from php simly use...

http://php.net/manual/en/function.mysql-connect.php

look at here..... example 2

<?php
// we connect to example.com and port 3307
$link = mysql_connect('example.com:3307', 'mysql_user', 'mysql_password');
if (!$link) {
die('Could not connect: ' . mysql_error());
}
echo 'Connected successfully';
mysql_close($link);

// we connect to localhost at port 3307
$link = mysql_connect('127.0.0.1:3307', 'mysql_user', 'mysql_password');
if (!$link) {
die('Could not connect: ' . mysql_error());
}
echo 'Connected successfully';
mysql_close($link);
?>

jcmtnez
jcmtnez's picture
Offline
Last seen: 3 years 1 month ago
Joined: Jul 9 2011
Junior Boarder

Posts: 4

Juan Martinez
Re: how to connect infinidb with php??

Yes, that's exactly what I have been doing from the begining with no luck. If you are able to connect to infinidb as stated on the PHP manual then it is possible that something is wrong with my install.

I've done PHP for quite some time and I'm familiar with connecting to MySQL but I've never installed Infinidb before, so it would be more likely that my problem has to do with the install. I will re-install infinidb and will report back.

Thanks to all.

rasel200209
rasel200209's picture
Offline
Last seen: 3 years 2 months ago
Joined: Nov 24 2009
Junior Boarder

Posts: 2

Rasel Ahmed
Re: how to connect infinidb with php??

yes I have successfully connected in this way. and it works nice for me...

abhishek.wankhede
abhishek.wankhede's picture
Offline
Last seen: 2 years 6 months ago
Joined: Feb 29 2012
Junior Boarder

Posts: 4

Abhishek Wankhede
Re: how to connect infinidb with php??

add a new line there, of the port number you defined while installing infinidb. (i had given 3307)

var $port_number=3307;

and add this in the below string,
$link_id=mysql_connect($this->dbhost,$this->$port_number, $this->dbusername,$this->dbpassword);

I had done something like this and it worked.