I had a pressing need for mysql-5.1.40 to be installed for work reasons a couple of weeks ago, and found the state of mysql releases in gentoo to be lacking. I cobbled together the following ebuild using the binary RPM distribution from mysql.com. It should probably be called "mysql-bin", but whatever.
inherit eutils rpm
# http://dev.mysql.com/get/Downloads/MySQL-5.1/MySQL-server-5.1.40-0.glibc23.x86_64.rpm/from/pick
MY_P=MySQL-server-${PV}
SRC_URI="http://dev.mysql.com/get/Downloads/MySQL-5.1/MySQL-server-${PV}-0.glibc23.x86_64.rpm
http://dev.mysql.com/get/Downloads/MySQL-5.1/MySQL-client-${PV}-0.glibc23.x86_64.rpm
http://dev.mysql.com/get/Downloads/MySQL-5.1/MySQL-shared-${PV}-0.glibc23.x86_64.rpm
http://dev.mysql.com/get/Downloads/MySQL-5.1/MySQL-devel-${PV}-0.glibc23.x86_64.rpm"
DESCRIPTION="MySQL-5.1.40 RPM"
HOMEPAGE="http://www.mysql.com"
LICENSE="GPL-2"
SLOT="0"
KEYWORDS="amd64"
IUSE=""
src_install() {
dobin usr/bin/*
dosbin usr/sbin/*
dolib usr/lib64/*
insinto /usr/include/mysql
doins usr/include/mysql/*
insinto /usr/share/aclocal/mysql
doins usr/share/aclocal/mysql.m4
dodoc usr/share/doc/MySQL-server-5.1.40/*
doman usr/share/man/man1/*
doman usr/share/man/man8/*
insinto /usr/share/mysql
doins usr/share/mysql/*
insinto /usr/share/mysql/charsets
doins usr/share/mysql/charsets/*
insinto /usr/share/mysql/english
doins usr/share/mysql/english/*
#/etc/logrotate.d
#/etc/logrotate.d/mysql
}