mysql5.58的编译安装(转)
时间:2011-01-27 来源:vicowong
cmake-2.8.3.tar.gz
mysql-5.5.8.tar.gz
一,cmake-2.8.3的安装:
tar -zxf cmake-2.8.3.tar.gz
cd cmake-2.8.3
[root@localhost cmake-2.8.3]# ./configure
[root@localhost cmake-2.8.3]#make;make install
二,mysql5.58的安装:
1,建立mysql用户和组
[root@localhost ~]# groupadd -g 2001 mysql
[root@localhost ~]# useradd -M -s /sbin/nologin -u 2001 -g 2001 mysql
2,编译mysql的安装
[root@localhost amp]# tar -zxf mysql-5.5.8.tar.gz
[root@localhost amp]# cd mysql-5.5.8
[root@localhost mysql-5.5.8]# cmake . \
> -DCMAKE_INSTALL_PREFIX=/usr/local/mysql5 \
> -DINSTALL_DATADIR=/usr/local/mysql5/data \
> -DDEFAULT_CHARSET=utf8 \
> -DEXTRA_CHARSETS=all \
> -DMYSQL_USER=mysql
[root@localhost mysql-5.5.8]#make;make instal
[root@localhost ~]# mv /etc/my.cnf /etc/my.cnf.bak
[root@localhost ~]# cp /usr/local/mysql5/support-files/my-medium.cnf /etc/my.cnf
[root@localhost ~]# vi /etc/my.cnf
(在mysqld下方加入两条参数)
basedir=/usr/local/mysql5
datadir=/usr/local/mysql5/data
[root@localhost ~]# cd /usr/local/mysql5/
[root@localhost mysql5]# scripts/mysql_install_db \
--user=mysql \
--basedir=/usr/local/mysql5 \
--datadir=/usr/local/mysql5/data
[root@localhost mysql5]# chown -R mysql:mysql /usr/local/mysql5/data/
[root@localhost mysql5]# chgrp -R mysql /usr/local/mysql5/
[root@localhost mysql5]# bin/mysqld_safe --user=mysql &
[root@localhost mysql5]# bin/mysqladmin -u root password 123456
[root@localhost mysql5]# bin/mysql -uroot -p123456
mysql> show databases;
3,把mysql加入到系统服务中
[root@localhost mysql5]# cp support-files/mysql.server /etc/rc.d/init.d/mysqld
[root@localhost mysql5]# chkconfig --add mysqld
[root@localhost mysql5]# chkconfig --list | grep mysql
mysqld 0:off 1:off 2:on 3:on 4:on 5:on 6:off
[root@localhost mysql5]# service mysqld status
MySQL running (20047) [ OK ]
[root@localhost mysql5]# service mysqld restart
Shutting down MySQL. [ OK ]
Starting MySQL.. [ OK ]
[root@localhost mysql5]# /etc/rc.d/init.d/mysqld restart
Shutting down MySQL. [ OK ]
Starting MySQL.. [ OK ]