Installing MySQL on Vista

Posted by John
on Sunday, 30 March 2008

Easy it aint, kept getting this...

The application has failed to start because its side-by-side configuration is incorrect. Please see the application event log for more detail.

But here's how to fix it,

Get MySQL

First download MySQL

Install MySQL

Now unzip the executable and install it, when it's finished and asking you if you want to run the configuration tool, don't; we'll deal with this in a minute.

Install Resource Hacker

Now to fix the MySQL Instance Configuration Tool, so it will install the MySQL service in Vista, download Resource Hacker...

Unzip it and open it's folder, then Right-Click on ResourceHacker and Run as Administrator.

Edit Resources

Now using Resource Hacker open the file...

  • C:\Program Files\MySQL\MySQL Server 5.0\bin\MySQLInstanceConfig.exe

Navigate to 24 / 1 / 1033 and look at the config on the left. On line 6 you should see asAdministrator, change this to requireAdministrator then click Compile Script; then finally Save the file.

Run MySQL Instance Config

Finally run the MySQL Instance Configuration tool from within...

  • C:\Program Files\MySQL\MySQL Server 5.0\bin\MySQLInstanceConfig.exe

This should now be able to create the system service and finally give you MySQL running on Windows Vista.

Building a 1U Server, Part 3

Posted by John
on Monday, 17 March 2008

server

System Config

While the final bits arrive for my new server project I might as well put pen to paper on how the server's O/S will be laid out.

The operating system I'm rooting for this time around will be Linux, purely for the flexibility and the stability; the hardware I'll have to run thru it's paces with a CPU testing tool to make sure i've not got a faulty chip along with some brute-force testing on the memory chips, it's going in co-location so I might as well do it as I don't want to drive down to the site everytime it falls over.

I'll be using SSH obviously to connect to it along with a strong keychain to make my logging in easier and the connection encrypted.

I've got a strong iptables config so will put that into play with a custom port for SSH, not the usual port 22 which is standard; the more things you put in the way of potential hackers the better.

And no, I won't be logging in as root, only if I absolutely have to.

System Layout

This is the tricky bit, working out how you're going to lay the system out and run the various services; there really isn't any good answer, no one solution will fit everything.

For me I've decided to use XEN virtualisation to segregate my services out so each one remains separate, not all my eggs in one basket.

So I plan to use XEN and ArchLinux to handle each server stack, e.g.

  • Database Server (MySQL / PostGreSql / Sqlite)
  • PHP Server (Lighttpd + PHP5)
  • Rails Server (Nginx, Thin, Ruby on Rails 2.0)
  • Caching Server (Memcache, or some kind of custom Content Delivery Network)

I haven't nailed down the particular distro of Linux for the core o/s but will be using ArchLinux to handle the 'baby' boxes, the controlling 'big-daddy' may either be Fedora or again ArchLinux.

Now this may sound like overkill, but it does make sense, as it'll allows me to custom-build each Server based on it's proposed use and with ArchLinux I can make sure no extra baggage is added with unneccesary features and services; tuning it to the maximum performance.

It also allows me to do image backups in the future of each server so I can take snapshots of each one, in case I need to restore any at a certain point in time (say a bad update).

ArchLinux?

I've grown to enjoy ArchLinux, mainly for it's neatness and light feature stack, but also because it has no set release number. Unlike other distro's there is no frozen release 7 or 8, you go with the latest core files and that's what you've got; taking the pressure out of always being on-top.

Also the package manager is a little more powerful and because you only install what you need you don't end up with tons of extra software you never even use. Rolling in at a 160mb ISO build compared to 4.4GB for your average Ubuntu or Fedora you know you're only getting the bare-bones.

As Judd Vinet, the founder of the Arch Linux project said: "It (Arch Linux) is what you make it."

Don't get me wrong, I'm not trying to bash any of the other distro's but as you can imagine with this particular project I have to keep things lean so I can maximise power and alleviate future problems when trying to identify awol services.

Final Notes

It's going to be a lot of work and probably a pain in the rear to put together but I've done this long enough with SliceHost and Virtual Hosting so I think I've cut my teeth long enough to do this for real.

Keep you posted how the build goes.

Rails Sessions

Posted by John
on Sunday, 09 March 2008

rails is love

To make a truly intelligent web application your gonna sooner or later have to play around with Sessions, which is basically a Cookie's big brother.

Store in DB

Now Rails initally will store all it's session data in a text file within the /tmp/sessions directory of your rails app, which is usually ok, but if you're gonna build a production-ready app you're gonna want to up the ante somewhat and store them in your DB.

This is simply done by opening up your environment.rb file and un-commenting the following line...

(within /config/environment.rb) config.actioncontroller.sessionstore = :activerecordstore

Then in the command-line generate a RAKE DB migration for your Session objects (so they're stored in your db from now on).

rake db:sessions:create rake db:migrate

Bingo, you now have a table within your database hooked up and ready to store your session data perfectly.

Storing Session Objects

Now that you've got your DB storing your session data, why don't we start creating some session objects.

This is done by...

session[:order] = 'ASC'

Here, we've simply created a new session object, storing in it a text value of 'ASC'; cool eh?

We can then check to see if our session is empty via...

if session[:order].blank? ..do stuff..

So if our session object contains nothing we can initialise it correctly.

Common Gotcha

Now one of the good things with switching sessions over to your db is that it'll secure your app a little bit better and your performance will improve.

Plus if your building your app on your dev machine, then transfer it to your live box, but can't find a reason why your sessions don't work there it's usually down to file permissions for the session file; by switching sessions over to a db you remove any future problem of this.

Good eh,

ImageMagick + MySQL on Fedora

Posted by John
on Saturday, 23 February 2008

ImageMagick

From the terminal...

sudo yum install freetype freetype-devel libjpeg libjpeg-devel libpng libpng-devel libtiff libtiff-devel ImageMagick ImageMagick-devel ghostscript ghostscript-devel ghostscript-fonts libwmf libexif

This will install ImageMagick and all the development libraries to get it working.

And for the ruby gem...

sudo gem install rmagick

MySQL

First MySQL...

sudo yum install ruby-devel mysql mysql-devel mysql-server

Then the Ruby gem...

sudo gem install mysql -- --with-mysql-config=/usr/bin/mysql_config

Starting MySQL

Now in Terminal do...

/sbin/chkconfig mysqld on
/sbin/service mysqld start

That should enable the mysql services on your Fedora machine.

Services Running on Startup?

Do this to see what is actually running when you power up...

/usr/sbin/ntsysv

And finally to cleanup your System...

sudo yum clean all

Convert InnoDB > MyISAM and Back Again...

Posted by John
on Friday, 28 December 2007

Convert Typo InnoDB > MyISAM

Simple script to convert your Typo database tables from InnoDB to MyISAM format.

use mytypo_production;
ALTER TABLE articles_tags ENGINE = MyISAM;
ALTER TABLE blacklist_patterns ENGINE = MyISAM;
ALTER TABLE blogs ENGINE = MyISAM;
ALTER TABLE categories ENGINE = MyISAM;
ALTER TABLE categorizations ENGINE = MyISAM;
ALTER TABLE contents ENGINE = MyISAM;
ALTER TABLE feedback ENGINE = MyISAM;
ALTER TABLE notifications ENGINE = MyISAM;
ALTER TABLE page_caches ENGINE = MyISAM;
ALTER TABLE pings ENGINE = MyISAM;
ALTER TABLE redirects ENGINE = MyISAM;
ALTER TABLE resources ENGINE = MyISAM;
ALTER TABLE schema_info ENGINE = MyISAM;
ALTER TABLE sessions ENGINE = MyISAM;
ALTER TABLE sidebars ENGINE = MyISAM;
ALTER TABLE sitealizer ENGINE = MyISAM;
ALTER TABLE tags ENGINE = MyISAM;
ALTER TABLE text_filters ENGINE = MyISAM;
ALTER TABLE triggers ENGINE = MyISAM;
ALTER TABLE users ENGINE = MyISAM;

Now What?

Change mytypo_production to your Typo database's name.

Save it as convert.sql

Run it via,

mysql -u root
source convert.sql

You will get a load of check messages and hopefully no errors or warnings. If all goes ok you should now be over to MyISAM.

Convert Typo MyISAM > InnoDB

use mytypo_production;
ALTER TABLE articles_tags ENGINE = INNODB;
ALTER TABLE blacklist_patterns ENGINE = INNODB;
ALTER TABLE blogs ENGINE = INNODB;
ALTER TABLE categories ENGINE = INNODB;
ALTER TABLE categorizations ENGINE = INNODB;
ALTER TABLE contents ENGINE = INNODB;
ALTER TABLE feedback ENGINE = INNODB;
ALTER TABLE notifications ENGINE = INNODB;
ALTER TABLE page_caches ENGINE = INNODB;
ALTER TABLE pings ENGINE = INNODB;
ALTER TABLE redirects ENGINE = INNODB;
ALTER TABLE resources ENGINE = INNODB;
ALTER TABLE schema_info ENGINE = INNODB;
ALTER TABLE sessions ENGINE = INNODB;
ALTER TABLE sidebars ENGINE = INNODB;
ALTER TABLE sitealizer ENGINE = INNODB;
ALTER TABLE tags ENGINE = INNODB;
ALTER TABLE text_filters ENGINE = INNODB;
ALTER TABLE triggers ENGINE = INNODB;
ALTER TABLE users ENGINE = INNODB;

Also...

Also make sure you Tune your MySQL Install...

And optimize the Tables,