MySQL Cluster API Developer Guide  /  MySQL NoSQL Connector for JavaScript  /  Installing the JavaScript Connector

5.2 Installing the JavaScript Connector

This section covers basic installation and setup of the MySQL JavaScript Connector and its prerequites. The Connector requires both Node.js and MySQL Cluster to be installed first; you can install these in either order. In addition, the mysql-js adapter requires the node-mysql driver. Building the Connector also requires that your system have a working C++ compiler such as gcc or Microsoft Visual Studio.

To install all of the prerequisites for the JavaScript Connector, including node-mysql, you should perform the following steps:

  1. Node.js.  If you do not already have Node.js installed on your system, you can obtain it from In addition to source code, prebuilt binaries and installers are available for a number of platforms. Many Linux distributions also have Node.js in their repositories (you may need to add an alternative repository in your package manager).

    MySQL Cluster 7.3.1 requires Node.js version 0.7.9 or earlier, due to dependency on node-waf. MySQL Cluster 7.3.2 and later use node-gyp (see, and should work with Node.js 0.8.0 and later.

    Regardless of the method by which you obtain Node.js, keep in mind that the architecture of the version you install must match that of the MySQL Cluster binaries you intend to use; you cannot, for example, install the JavaScript Connector using 64-bit Node.js and 32-bit MySQL Cluster. If you do not know the architecture of your existing Node.js installation, you can determine this by checking the value of global.process.arch.

  2. MySQL Cluster.  If MySQL Cluster, including all header and library files, is not already installed on the system, install it (see MySQL Cluster Installation).

    As mentioned previously, you must make sure that the architecture (32-bit or 64-bit) is the same for both MySQL Cluster and Node.js. You can check the architecture of an existing MySQL Cluster installation in the output of ndb_mgm -V.

  3. node-mysql driver.  The mysql-js adapter also requires a working installation of the node-mysql driver from You can install the driver using the Node.js npm install command; see the project web site for the recommended version and package identifier.

Once the requirements just listed are met, you can find the files needed to install the MySQL Connector for JavaScript in share/nodejs in the MySQL Cluster installation directory. (If you installed MySQL Cluster as an RPM, this is /usr/share/mysql/nodejs.) To use the Node.js npm tool to perform a best-guess installation without any user intervention, change to the share/nodejs directory, then use npm as shown here:

shell> npm install .

The final period (.) character is required. Note that you must run this command in share/node.js in the MySQL Cluster installation directory.

You can test your installation using the supplied test program. This requires a running MySQL Cluster, including a MySQL Server with a database named test. The mysql client executable must be in the path.

To run the test suite, change to the test directory, then execute command shown here:

shell> node driver 

By default, all servers are run on the local machine using default ports; this can be changed by editing the file test/test_connection.js, which is generated by running the test suite. If this file is not already present (see Bug #16967624), you can copy share/nodejs/test/lib/test_connection_js to the test directory for this purpose.

If you istalled MySQL Cluster to a nondefault location, you may need to export the LD_LIBRARY_PATH to enable the test suite. The test suite also requires that the test database be available on the MySQL server.

MySQL Cluster NDB 7.3.1 also provided an alternative build script in share/node.js/setup; this was removed in MySQL Cluster NDB 7.3.2 and later MySQL Cluster NDB 7.3 releases.

User Comments
Sign Up Login You must be logged in to post a comment.