Skip to content

Installing nk mysql on Windows

Richard Winters edited this page Feb 23, 2015 · 3 revisions

Pre-Installation Notes

This documentation is based on Windows 8.1 x86_64.

Installation on Windows is rather straight-forward. Typically I provide pre-compiled binaries for Windows since build tools are not so freely accessible.

  • If you'd like to help support other systems please submit a pull request. I do not own a Mac nor run SunOS.

Just a note: Building is not difficult what-so-ever. Yes there may be some prerequisites but it's really not that bad.

Prerequisites

####Non-buildage

  1. Git (Latest, required by Node-js)
  2. Node-js (x86 or x64, the architecture should match your MySQL Community Server Installation)
  3. MYSQL Community Server 5.5+ (if node.js is 64-bit, so should be your mysql server). At this time 5.6.x is recommended, build did not complete properly using 5.7.4-m14 dev release.

Yes, Boost is only required for building - NOT for using. If you are not building, and meet these prerequisites you can move on to The Actual Install.

####Buildage

  1. Git (Latest, required by Node-js)
  2. Node-js (x86 or x64, the architecture should match your MySQL Community Server Installation)
  3. Python (2.7.x x86 or x64, required by node-gyp)
  4. node-gyp (Install via Node: npm install node-gyp -g)
  5. MYSQL Community Server 5.5+ (if node.js is 64-bit, so should be your mysql server). At this time 5.6.x is recommended, build did not complete properly using 5.7.4-m14 dev release.
  6. Boost headers. You are not required to build any boost libraries.

Note regarding MySQL Server when building

  • On Windows, there is no mysql_config binary - so we need the system variable MYSQL_DIR to be set. It should point to the directory which contains the include and lib folders. This is typically found at c:\program files\MySQL\Server 5.X\.

Note regarding Boost when building

  • Since boost on Windows is typically a custom or manually managed installation; you will need to ensure that the system variable BOOST_ROOT is set. You will almost always have to do this manually. Be sure to get a copy of Boost 1.55.0+, extract it, and copy the 'boost' folder to a location of your choosing or to c:\boost\boost_1_XX_X\. Set the location to the directory containing the boost folder as a value for BOOST_ROOT. Make sure its the directory containing the boost directory you are setting a path to, the boost directory which contains all the header files (it typically resides 1-2 levels down from the resulting extracted directory)

Prerequisite Recap & Additional Information for building

  • On Windows, there is no mysql_config binary - so we need MYSQL_DIR to be set.
  • If it wasn't already apparent, you need Visual Studio to build. To build x64 you will need a paid version. You must use VS201X x64 Native Command Tools in place of Command prompt to build 64-bit. I recommend using VS201X x86 Native Command Tools even if you are building 32-bit as the Native Command Tools are properly configured for development - unlike Command Prompt.
  • Keep in mind that if you're on a 64-bit system and want a 32-bit build; you should install node.js x86 and mysql x86. If you want a 64-bit build, but do not have 64-bit build tools or are on a 32-bit system, then you're out of luck; install node.js x86 and mysql x86. If you want a 64-bit build, are on a 64-bit system, and have the 64-bit build tools; install node.js x64 and mysql x64.

If you meet the above requirements, you're ready to build. That wasn't bad at all huh?

The actual install

To install (installing is how we build too!); open a terminal and cd to the root of your application. Run the following command:

path_to_application/> npm install nk-mysql

One thing to note, is that if you are not building - you may need to add the path containing libmysql.dll to the system PATH variable, or place a copy of libmysql.dll and its lib file within the root of the application making use of nk-mysql. You'll know if you need to do this when you try to make use of the module.

Test your install

Browse to the root of your nodamysql module/addon:

path_to_nk-mysql/>  npm test

And watch ~45 various queries of various types execute successfully.

If you get a missing library error when trying to run the test, the resolution is the same as installation - copy libmysql.dll and its lib file to the root of the nk-mysql directory.