You'll probably want to have a look at section 5.10 in the manual:
Also, the mysqld_multi documentation may come in handy:
Lou Olsten wrote:
> We have successfully (and easily) installed multiple versions of MySQL on
> Windows and are now trying to do the same on Linux.
> We have a Fedora machine successfully running 4.1, but we want to add 5.0 to
> it as well. We installed 4.1 with RPM, so it put a bunch of MySQL files all
> over the place.
> I've downloaded the 5.0 tar and unpacked it into its own directory, then ran
> the install_db script. It ran OK, but no data files were created in the
> mysql or test directories; they're both empty.
> Does this sound right? Is there a step-by-step guide to installing multiple
> versions on the same box? I've been through the docs and while they address
> management of multiple, and a vague instruction on installing, it doesn't
> appear to be that detailed.