环境:RHEL 3、mysql-5.0.22 源代码包(下载地址:http://download.mysql.cn/src/2006/0710/5544.html)
用 root 用户执行以下步骤:
groupadd mysql
useradd -g mysql mysql
cd /usr/local
tar zxvf /root/mysql-5.0.22.tar.gz # MySQL 源代码包的绝对路径
cd mysql-5.0.22
./configure --enable-thread-safe-client --with-unix-socket --with-mysqld-user=mysql --with-charset=gbk --prefix=/usr/local/mysql
make # 这一步时间较长
make WITH_XCHARSET=gbk,bg2312 install
scripts/mysql_install_db
chown -R root /usr/local/mysql
chown -R mysql /usr/local/mysql/var
chgrp -R mysql /usr/local/mysql
cp support-files/my-medium.cnf /etc/my.cnf #the configure file of mysql database (three mode)
/usr/local/mysql/bin/mysqld_safe & # 启动 MySQL
/usr/local/mysql/bin/mysqladmin -u root password 'new-password' # 修改 MySQL root 用户口令
自动运行MySQL 在MySQL二进制包里面,有一个叫myslq.server的启动脚本程序。把它复制到/etc/init.d目录里面: # cd /etc/init.d # cp /usr/local/mysql/support-files/mysql.server mysql 接着把它的属性改为“x”(executable,可执行) # chmod +x mysql 最后,运行chkconfig把MySQL添加到你系统的启动服务组里面去。 # /sbin/chkconfig --del mysql # /sbin/chkconfig --add mysql