logo logo

Setting up NWNX2 with MySQL on Windows using the MySQL plugin

by Urlryn

www.sunshadow.org/MySQLSetup.htm

used with permission

 

Note: This tutorial is somewhat outdated by now. We recommend using the ODBC2 plugin, the descendant of the original ODBC NWNX plugin which includes everything and more than the NWNX mysql plugin did.

 

Using MySQL/NWNX2 with NWNX MySQL Module on Win32 systems

 

(This walk thru is cobbled together from other peoples posts and various readme’s and manuals)

 

I wrote this after hours of working on my own server and decided next time I have to do this it will be much easier to do without all the searching. So figured I’d share this more in-depth walk thru.

 

Hopefully its complete!

 

1. Download Software

 

MySQL Database server version 4.0.20d

MySQL Control Center

dev.mysql.com/downloads/index.html

 

ASP/NWNX version 2.5.3 by Papillon

nwnx.org

 

NWNX MySQL Add-on by Jeroen Broekhuizen

(Reason for going with Add-on is a faster connection to your Database)

nwvault.ign.com/Files/other/data/1089589607000.shtml

 

For some reason Jeroen’s newest Add-on upload isn’t complete or has been messed up.

 

Here is the link for the version I have used in this walkthrough.

www.sunshadow.org/files/NWNX mysql plugin.rar

 

2. Install MySQL Database Server version 4.020.d

 

3. Install MySQL Control Panel

 

4. Extract NWNX MySQL Add-on

 

a. Copy/Paste only the files inside the SOURCE and RUNTIME folders to the Root of your NWN folder

 

(Default is C:\Neverwinternights\NWN)

Or

(C:\NWNDedicated Server)

 

b. Browse to your respective folder and open the nwnx_mysql.txt file and complete

 

Server = Localhost

User = nwnuser

Password = nwnuser

DB = nwn

 

c. Save and exit

d. Rename nwnx_mysql.dll file to nwnx_odbc.dll

 

5. Choosing a MySQL server type

 

You may want to read up on the differences between them, but I normally use mysqld-max-nt

 

For Windows 98 and ME you may have to just use mysqld-max

 

6. Install and Launching the MySQL database engine as a MS Windows Service

  1. click on start
  2. click on run
  3. Type> cmd
  4. Type> cd c:\mysql\bin
  5. Type> mysqladmin -u root shutdown
  6. Type> mysqld-max-nt –install (This command does not work for Win98 or ME)

Do not exit from the command prompt yet!

 

Once a MySQL server is installed as a service, Windows will start the service automatically whenever Windows starts.

 

The service also can be started immediately from the Services utility, or by using the command NET START MySQL. The NET command is not case sensitive

 

7. Setup of the Root and User/Anon Accounts and Password

 

a. First we will set the Root Password since by default it is blank

  1. Return to the command prompt window
  2. Type> mysql -u root (should put you at the mysql prompt)
  3. Type> SET PASSWORD FOR 'root'@'localhost' = PASSWORD('typepasswordhere');
  4. hit enter and you should see Query OK, 0 rows affected (0.00 sec)

 

b. Next we are going to remove any default anonymous accounts for security:

  1. Type> DELETE FROM mysql.user
  2. hit enter
  3. Type> WHERE User = '';
  4. hit enter
  5. Type> FLUSH PRIVILEGES;
  6. Hit enter and you should see Query OK, 0 rows affected (0.00 sec)

 

c. Now we will create the nwnuser account

  1. Type> GRANT ALL PRIVILEGES ON *.* TO 'nwnuser'@'localhost'
  2. Hit enter
  3. Type> IDENTIFIED BY 'nwnuser' WITH GRANT OPTION;
  4. Hit enter and you should see Query OK, 0 rows affected (0.00 sec)
  5. Type> SET PASSWORD FOR 'nwnuser'@'localhost' = PASSWORD('nwnuser');
  6. Hit enter and you should see Query OK, 0 rows affected (0.00 sec)
  7. Type> quit (this should put you back to the normal command prompt)

 

Don’t close the command prompt cause we will return to this shortly

 

8. Create the nwn server (using MySQL Control Console)

 

Open MySQL Control Console

On the left hand side inside the box under “MySQL Server” right click and select new

 

Fill in the correct information:

name = nwn
hostname = localhost
user = nwnuser
pass = nwnuser

 

Click test and a box should appear saying a connected was established

 

**If you get this error: ERROR 2003: Can't connect to MySQL server on 'localhost' (10061)

**Check Services utility to be sure MySQL is running

 

Click add

(Optional) Once connected right click your server nwn and select edit.

(Optional) Click on the MySQL Options Tab

(Optional) Change the settings for "Automatically limit SELECT queries to" to a higher number of your choice

 

9. Create an nwn database

  1. Select the new database server called “nwn” and right click on it and select connect
  2. Select the database folder and right click and select New database
  3. Type> nwn
  4. Right click the database folder and click refresh (Should see a Grey Cylinder named nwn)
  5. Right click nwn and click connect (should turn green). Now leave this open in the background

 

Create the PWData Table:

Create a new text file in the C:\mysql\bin folder and name it db.txt

open db.txt

copy this into the text file:

 

USE nwn;

CREATE TABLE pwdata (

player varchar(64) default '',

tag varchar(64) default '',

name varchar(64) default '',

val text,

expire int(11) default '0',

last timestamp(14) NOT NULL,

KEY idx (player,tag,name)

) TYPE=MyISAM;

 

Exit and save

Now lets go back to that command prompt window

Type> mysql -u nwnuser -p databasename < db.txt

 

Note: Databasename = nwn

 

-p means you will be prompted for a password for your nwuser account…which btw is nwnuser!

 

11. Installing ASP/NWNX2

  1. Extract the files “NWNX2.exe", "nwnx-module.dll", and "madCodeHookLib.dll" to your Neverwinter Folder. (Default is C:\Neverwinternights\NWN)
  2. Extract the file "aps2.erf" into the C:\Neverwinternights\NWN\erf directory.
  3. In the toolset, open up the module into which you wish to install the scripts.
  4. Under the File Menu, click Import. A window will pop up.
  5. Make sure the contents of the C:\Neverwinternights\NWN\erf directory are showing in the window
  6. Select "aps2.erf" from the list
  7. Click Import and ignore the message about the missing resource (click Yes).
  8. After installing according to the instructions above, go to Module Properties under the Edit menu.
  9. Select aps_onload for your module OnModuleLoad event OR
  10. Open aps_onload in the script editor and paste the contents of it into your pre-existing module's OnModuleLoad script. We only recommend doing this if you are familiar with NWScript.

 

Note: You can auto start a module using the command "NWNX2.exe" -module “MODULENAME”