Support → Documentation → Stunnix Advanced Web Server Extensions

# Introduction

This extension allows Perl and PHP scripts to use MySQL server.

The implementations of extension should be extracted to `/extensions/engines`.

The implementations for this extension have the following sizes on CDROM: Windows: 8Mb, Linux: 10Mb, MacOSX: 8.5Mb.

Implementations of this extension are not included with distribution of SPWS, one has to download them separately and put to appropriate directory.

# Details

No options can be passed to this extension using /site/config/extlist.conf file.

The deployment versions of this extension lack all files that are not needed for running MySQL server and doing essential administration. The only executables provided are mysql server itself, mysqladmin and mysql commandline client. All documentation and various utilities for exporting/importing/repairing MySQL databases are not included.

Full version of MySQL (for development stage) should be acquired from www.mysql.com. It's not recommended to extract versions available from there to the `/extensions/engines`, see below for more details. Implementations of MySQL available from us for all platforms do not have any dependencies since all third-party libraries are statically compiled into them, so they don't require any non-standard libraries installed on user's computer to run.

# Putting database files to proper place

All database files should not be put to 'data' directory inside the implementation's installation root, please copy the contents of './data' directory to `/extensions/data/mysql_data`; the database files are managed by mysql_data extension (that allows database files to remain on CDROM, or be copied during first use of SPWS or each time SPWS is started) - see documentation of mysql_data extension for more information. MySQL server will automatically be configured to use the proper directory (the directory on CDROM or the copy of it in user's private files directory - depending on options specified for mysql_data extension) as location of database files).

# Using proper port number to connect to MySQL server in scripts

The port number MySQL server will accept connections on is determined automatically at startup as first free available port. It will be listed as default port for MySQL in php configuration file, so PHP scripts won't have to be changed at all (unless they hardcode mysql port number - but these scripts should be considered incorrectly-written). Also the port number MySQL listens on will also be exported in the `MYSQL_PORT` environment variable, so all Perl scripts should specify port number explicitly in the DBI data source string.

# Finding MySQL error messages and runtime-properties

A directory Stunnix Advanced Web Server stores application-specific files permamently (it's name is contained in the $ENV{STUNNIXWS_STATEDIR} variable (or, in case once_to_permdir was used for copy_to_hdd parameter to mysql_data extension, in $ENV{STUNNIXWS_PERMSTATEDIR} ) and is (unless copy_to_hdd=once_to_permdir is used) typically /home/user-name/.stunnixws/SITEID on Linux/Unix and MacOSX , c:\Documents and settings\USERNAME\Local Settings\Temp\.stunnixws\SITEID\ on Win2k and above and c:\windows\temp\.stunnixws\SITEID\ on Win9x and WinME ) - also contains files that with information about MySQL server. File named 'mysql-port.txt' contains port number MySQL server runs on, 'mysql-stderr.txt' and 'mysql-stdout.txt' - standard error log and standard output log file. Also 'mysql_data/USERNAME.err' contains the additional trace information from MySQL. So if you wish to inspect database using commandline 'mysql' client, find out port number in 'mysql-port.txt' (suppose it's 9002) and start mysql client (bin/mysql or bin/mysql.exe) using commandline

    mysql --port=9002 --host=127.0.0.1

Probably you will also have to add '--user=root' commandline switch.

# Preparing database files

First of all, suppose you have a MySQL database you wish to put on CDROM. First you will need to grant everybody all access to it. Start mysql client, and enter

    grant all on *.* to ''@'%';

This should be enough. Though sometimes it may be necessary to also execute:

    grant all on *.* to 'root'@'%';
    grant all on *.* to 'root'@'127.0.0.1';

NOTE: none of the GRANT commands above are needed if using Stunnix Advanced Web Server version 2.1 and above!!

Then stop MySQL server and copy all database files to `/extensions/data/mysql_data`. That's all!

# Rebuilding MySQL

It's of course possible to rebuild MySQL yourself, in case you need version of MySQL different from what we provide.

So after getting distribution version of MySQL, just leave all files we've left in our version. For Windows version, execute commands 'exetype mysqld.exe WINDOWS' and 'exetype mysqladmin.exe WINDOWS' to turn executables from Win32 Console Applications into Win32 GUI applications in order console window not to appear when mysql server is started or stopped during startup or shutdown of Stunnix Advanced Web Server.

Feel free to contact us for more information.