Setting up MySQL server on Windows from a no_install.zip

Carl on May 1st 2014 | Tags: , , ,

Extract the archive to your prefered location. Start the server with:
shell> {DRIVE:\PATH TO MySQL SERVER DIRECTORY NAME}\bin\mysqld
Stop the server with:
shell> {DRIVE:\PATH TO MySQL SERVER DIRECTORY NAME}\bin\mysqladmin -u root shutdown

If you want to have MySQL’s data directory in a different location or on another disk, move the directory there. If doing so, you’ll need to use an option file (my.ini or my.cnf), and start the server with:
shell> {DRIVE:\LOCATION[\..\..]\MySQL SERVER DIRECTORY NAME}\bin\mysqld --defaults-extra-file={DRIVE:\PATH TO}\[my.ini or my.cnf]
Stopping server as mentioned above.

Common problems

If you’re using InnoDB and you get an error on startup like below, you can fix it easily by removing the ibdata1, ibdata2, and the ib_logfile* files from the data directory. After restarting you’ll see newly generated files in mysql’s data directory.

InnoDB: Error: log file .\ib_logfile0 is of different size 0 10485760 bytes
InnoDB: than specified in the .cnf file 0 25165824 bytes!
120112 5:16:30 [ERROR] Default storage engine (InnoDB) is not available
120112 5:16:30 [ERROR] Aborting

If you get an error like:

140430 22:27:43 [ERROR] [PATH TO......]\bin\mysqld: unknown variable mysql-data-dir=[DIRECTORY TO SPECIFIED DATA DIR]

You are using an old server parameter name. Replace ‘mysql-data-dir’ with ‘datadir’ in your my.ini/.cnf and start your server again

Server Settings

To see the values that a server will use based on its compiled-in defaults and any option files that it reads, use this command:
mysqld --verbose --help
To get an overview of all server parameters, go to: Tuning Server Parameters. The page will be helpfull with optimizing your server settings.

Option file

Have a look at this page: Using Option Files

Starting MySQL as a service

Before installing MySQL as a Windows service, you should first stop the current server if it is running by using the following command:
shell>{DRIVE:\PATH TO MySQL SERVER DIRECTORY NAME}\bin\mysqladmin -u root shutdown

Install the MySQL server as a service
To do so use this command:
shell>{DRIVE:\PATH TO MySQL SERVER DIRECTORY NAME}\bin\mysqld --install
or if you are using an option file:
shell> {DRIVE:\PATH TO MySQL SERVER DIRECTORY NAME}\bin\mysqld --install MySQL --defaults-file={DRIVE:\PATH TO OPTIONS FILE}
To start the service manual replace --install with --install-manual

Remove service

To remove a server that is installed as a service, first stop it if it is running by executing NET STOP MySQL. Then use the –remove option to remove it:
shell> {DRIVE:\PATH TO MySQL SERVER DIRECTORY NAME}\bin\mysqld --remove

Filed under MySQL | Comments Off

REST

Carl on Mar 25th 2013 | Tags: , ,

Sometimes a client wants to use/make use of a RESTfull service. If you do not have a lot of experience with that, you might visit the following site to inmprove your knowledge on it:

Tutorial

Filed under Programming | Comments Off

Install PHPUnit on WAMP

Carl on Jun 10th 2012 | Tags:

Before you can install PHPUnit you need to have installed PEAR. If that is not the case , you can do the following:

  • Go to wamp-directory, b.v. :
    C:\>cd wamp\bin\php\php5.3.0
  • To install PEAR, execute the following command:
    C:\wamp\bin\php\php5.3.0>go-pear.bat
    You will be asked several questions which you can leave to the default value.
  • The next thing you will need to do is register PEAR environmental variables in the registry. Therefore you can execute C:\wamp\bin\php\php5.3.0>PEAR_ENV.reg (Perhaps not a bad idea to backup your current registry!). Now you can call PEAR everywhere on the command line
  • If you cannot call PEAR on the command line, you will need to add the PEAR directory to the Windows environmental ‘Path’ variable. You can find that one in: System Properties -> Advanced-> Environment Variables. Select the ‘Path’ variable, click on ‘Edit’ , and add to the end of the line a ‘;’ and the path to the PEAR directory which in my case is: C:\wamp\bin\php\php5.3.0

Install PHPUnit

  • Register the PHPUnit channel in pear C:\wamp\bin\php\php5.3.0>pear channel-discover pear.phpunit.de
  • Install PHPUnit C:\wamp\bin\php\php5.3.0>pear install phpunit/PHPUnit
    of php5.3.0>pear install –alldeps phpunit/PHPUnit

If you get a warning your PEAR verzion is not high enough, you can upgrade your PEAR version:
...php5.3.0>pear upgrade pear

Filed under Miscellaneous,PHP | Comments Off

Set JAVA_HOME on *nix

Carl on Jun 8th 2012 | Tags: , , ,

If you have installed java (JRE/SDK), and you need for certain programs the system variable JAVA_HOME, you can initialyse it yourself.
Go to you home directory. Find your java install directory: which java
Edit .bashrc/.bash_profile (depends on your *nix flavour) and add:
export JAVA_HOME=[value from which java]
run:
source .bashrc/.bash_profile

READY!!!

You can check it with echo $JAVA_HOME

Filed under Linux | Comments Off

Windows – Disable Getting started/Welcome screen

Carl on Jun 7th 2012 | Tags: ,

1. Start > Run
2. Type in ‘regedit’ and press enter
3. Go down the tree HKEY_CURRENT_USER > Software > Microsoft > Windows > CurrentVersion > Run
4. One of the entries on the right is called ‘Welcome Center’. Delete it, and restart!

Filed under Miscellaneous | Comments Off

Amavisd-new init script problem

Carl on Jan 4th 2012 | Tags: ,

Recently I had to reinstall my mailserver, due to the usual f…-up one tends to make as root. After several hours of configuring packages (debian testing) I finally had it up and running. Unfortunately, one of my cronjobs failed. An error restarting amavis after the update of spamassassin. Luckilly, someone already had the solution for the failing init-script.
If you get the following error restarting/stopping amavis:

Stopping amavisd: (not running).
Starting amavisd: The amavisd daemon is already running, PID: [10966] (failed).

Check your /etc/init.d/amavis for the following line:
STOP="--stop --quiet --pidfile $PIDFILE --name ${DAEMONNAME}"
Comment it out like:
# STOP="--stop --quiet --pidfile $PIDFILE --name ${DAEMONNAME}"
and put the next line in:
STOP="--stop --quiet --pidfile $PIDFILE"

Short and sweet: your system is probably running amavisd-new as user amavis or amavisd instead of amavisd-new, as defined in the top of the file. What’s in a DAEMONNAME …
If that doesn’t work … you’ll be in for a nice google-session

Filed under Mail server | Comments Off

ADODB-change database

Carl on Aug 9th 2011 | Tags: ,

In ADODB you cannot use multiple database connections simultaneously. If you need to work cross database, you have two possibilities:

  • Close the existing connection en setup a new one so you can retrieve the required data from the database;
  • Change database.

Examples:
1. New Connection

$dbhandle = new ADONewConnection( $DSN_1 );
... queries etc. ...
$dbhandle->close ();
$dbhandle = new ADONewConnection( $DSN_2 );
... queries etc. ...
etc, etc

2. Change Database

$dbhandle = new ADONewConnection( $DSN_1 );
... queries etc. ...
$dbhandle->SelectDB ( $databasename );
... queries etc. ...

At first sight the differences do not seem to be very big. However, if your database server has a heavy load, it will certainly make a difference. The first option initialises a new connection every time (even with pconnect) and though you closed the previous connection, the latter still needs to timeout on the server. As a database server is no different then e.g. a web server in handling connections, this means you will be running out of connections (max connections in the server configuration), thus your code will be waiting for a response as the requested connections are being queued. Result for the web application … page timeouts.
The second option re-uses the existing connection. It will only switch from one database to the next. This, however, is only possible if the databases you use can be read by the same user from the same host, as you will understand. The bottleneck of this method is your service provider: Does he, if you are not the one providing the service, allow you to select/update/delete in your multiple databases with one account.

Filed under MySQL,PHP | Comments Off

Recursion (php3/4/5.0)

Carl on Mar 2nd 2011 | Tags: ,

Recursion should work fine in the latest versions. However, if it doesn’t read on and try another way …

PHP can be a bitch … One problem you will certainly encounter is when you want to call a function recursively. After you have been sweating on your code for half a day, a day, or maybe even longer, you will find that the initial value of your array|hash is no longer the same. It suddenly has diminished to a single value …

However, you can call a method recursively, not a function. Confusing? Yes, quite, as this means that you will only be able to use recursion in a class/object. It may seem you are writing functions in a class – you define them with ‘function’ – but it is a method your creating.

To call a method recursively, you cannot use the default way you would call a class method: ‘$this->methodname ([all your paramaters]);’. Recursion can only be established with: ‘classname::methodname([all your params);’. If you use the first method ‘$this->…’ you will experience the same frustration as with calling a normal function recursively. However, the second way to call your method – ‘class::method ..’ – puts you variable in a new instance, which does not know an previous values, and thus you can iterate recursively over your array|hash.

P.s. Watch out with static methods/functions

Filed under PHP | Comments Off

Class Variables PHP5

Carl on Feb 24th 2011 |

One nice quirck in PHP5:

If you write a class and use boolean variables in the class methods, you will need to initialise/declare it at the beginning of your method.

function methodenaam () {
$booleanvar = false;
...
}

If you ommit that, you will have the unexpected experience (in PHP5) that your variable will return ‘false’, even after you are 100% certain, it should be ‘true’. Anyway, it is a sign of good programming to declare/initialise your variables.

Filed under PHP | Comments Off

My Favorite Frameworks

Carl on Feb 12th 2011 |

During my time as programmer, I extended my experience (who does not?). One develops oneself, and learns how to program . Thus you define the way you write your code, your preferences, and so did I. That said, I also made use of frameworks. My favorite ones you will find below:

Php/DBS: ADODB, Doctrine
Php: Zend, Symfony
JavaScript: ExtJS (nu Sencha)

Filed under Frameworks | Comments Off

Older Posts »