[ start | index | login ]
start > knowledgebase > linux > miscapplications > rpm based mysql5 install

rpm based mysql5 install

Created by retep. Last edited by alex, one year and 16 days ago. Viewed 4,389 times. #36
[diff] [history] [edit] [rdf]
labels
attachments

Installing MySQL 5

Some newer distros (e.g. FC5 and newer and Ubuntu 6.10) have MySQL 5 by default. Older distros like WBEL3, Debian Sarge, and RHEL4 have MySQL 4.1 or older.

Mysql integrates with a few other apps so it is usually best to install it from a repository. Doing that may depend on what distro you are using

Running RHEL4?

You want to add the centosplus repository to your APT sources list (/etc/apt/sources.list), then update the package list and then install the newer version of mysqld and restart mysqld. Then you probably want to comment out that repository.

Run the following short bash script to do this for you:

{
if ! grep -qai '^rpm "http://mirror.centos.org/centos"' /etc/apt/sources.list ; then
echo 'rpm "http://mirror.centos.org/centos" /4/apt/i386 addons centosplus' >> /etc/apt/sources.list
addedcentos=1
fi
apt-get update
apt-get dist-upgrade -y mysql-server
/etc/init.d/mysqld restart
chkconfig --level 35 mysqld on
#sed --in-place 's%^rpm "http://mirror.centos.org/centos"%#rpm "http://mirror.centos.org/centos"%' /etc/apt/sources.list
}

Then comment out that centos entry from /etc/apt/sources.list (put a # at the start of the line).

Running Debian?

Try the >>http://dotdeb.org/ repository. Pop one of these entries >>http://dotdeb.org/mirrors into your /etc/apt/sources.list then apt get install mysql-server-5.0 (from memory).

Running WBEL3/RHEL3?

If you do not have a current RHEL3 MySQL database you are using, then you may hit some 'odd' errrors during MySQL 5 install (e.g. no mysql user, e.g. mysql not starting up, e.g. grant table issues). If so then run:

{
# install mysql-server if you aren't running it already
apt-get install mysql-server
/etc/init.d/mysqld start
# read in a password and set the password
if [ -z "$rootpasswd" ]; then
echo -n 'enter password '
read rootpasswd
fi
mysqladmin password $rootpasswd
# stop mysql
/etc/init.d/mysqld stop
}

Then run the following:

function installmysql() {
# latest version at time of posting
version=5.0.27-0
major=5.0
#rhel4 may also work
distro=rhel3
files="MySQL-client-standard-$version.$distro.i386.rpm MySQL-server-standard-$version.$distro.i386.rpm MySQL-shared-compat-$version.i386.rpm"
# if you have this directive mysql server will not install so comment it out
replace "^bdb_cache_size" "#bdb_cache_size" -- /etc/my.cnf
for file in $files; do 
    if [ -e $file ]; then continue; fi
    url=http://mysql.mirrors.pair.com/Downloads/MySQL-$major/$file; 
    echo getting $url
    wget $url
    if [ $? -ne 0 ] ; then echo failed getting rpm ; return 1; fi
done
/etc/init.d/mysqld stop
if [ ! -e /etc/my.cnf.orig ]; then
mv /etc/my.cnf /etc/my.cnf.orig
fi
rpm -Uvfh $files
# need the mysql user else mysql will not start up
adduser mysql; chown -R mysql:mysql /var/lib/mysql
/bin/mv -f /usr/share/mysql/my-small.cnf /etc/my.cnf
/etc/init.d/mysql restart
chkconfig --level 35 mysql on
}
installmysql

Stored Procedures

If your upgrading to MySQL 5 to use stored procedures, you need to run the mysql_upgrade script, and to get the full benefit of this upgrade it's a good idea to run these scripts.

I found I needed to run both these commands:

[root@vps ~]# mysql_upgrade
[root@vps ~]# mysql_fix_privilege_tables

For more information consult these docs:

请以发表评论身份登录
Powered by snipsnap.org Found a mistake in a howto? Let us know via an email to p.blikibugs at rimuhosting com.