Reputation: 189
I've installed MemSQL on a single server for testing and have created three tables as described in this example:
I can query the database from within the Memsql client running via ssh without any issues. However, whenever I try to run the same query programmatically in PHP I get the error "Table 'memsql_example.employees' is a distributed table. You cannot query it from a leaf".
The PHP code that generates that error is below:
<?php
$dbHost="127.0.0.1";
$dbUser="root";
$dbPass="";
$dbName="memsql_example";
$dbPort=3307;
// Connect to database
$mysqli = new mysqli($dbHost, $dbUser, $dbPass, $dbName, $dbPort);
if ($mysqli==false) die ("Error connecting to database\n");
$sql="select count(*) from employees;";
$result=$mysqli->query($sql);
if (!$result) {
printf("Errormessage: %s\n", $mysqli->error);
die();
}
?>
I've tried running the above script from another server by changing the $dbHost to point to the server IP rather than 127.0.0.1 but without success as I get the same error.
I've stared at this for hours - what am I doing wrong ?
Thanks in advance ...
Upvotes: 0
Views: 475
Reputation: 349
Queries in MemSQL should be directed against the aggregator, which by default will run on port 3306. It looks like you are querying port 3307, which will be a leaf by default in your configuration.
Upvotes: 1