Centos5.8 x86_64下安装mysql

编译安装mysql前先安装一些基础库文件

yum -y install gcc gcc-c++ autoconf libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel zlib zlib-devel glibc glibc-devel glib2 glib2-devel bzip2 bzip2-devel ncurses ncurses-devel curl curl-devel e2fsprogs e2fsprogs-devel krb5 krb5-devel libidn libidn-devel openssl openssl-devel cmake


主数据库:192.168.150.100

从数据库:192.168.150.101


创建mysql用户及用户组

groupadd mysql

useradd -g mysql mysql

mkdir -p /data/mysql

chown -R mysql:mysql /data/mysql


源码编译安装 mysql5.5.20

cd /usr/local/src/

tar zxvf mysql-5.5.20.tar.gz

cd mysql-5.5.20

cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_DATADIR=/data/mysql -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_unicode_ci -DWITH_READLINE=1 -DWITH_SSL=system -DWITH_EMBEDDED_SERVER=1 -DENABLED_LOCAL_INFILE=1 -DDEFAULT_COLLATION=utf8_general_ci -DWITH_MYISAM_STORAGE_ENGINE=1 -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_DEBUG=0

make && make install


cd /usr/local/src/mysql-5.5.20

cp ./support-files/my-huge.cnf /etc/my.cnf

cp ./support-files/mysql.server /etc/init.d/mysqld

chmod +x /etc/init.d/mysqld

chown -R mysql:mysql /usr/local/mysql


vi /etc/my.cnf

datadir=/data/mysql


/usr/local/mysql/scripts/mysql_install_db --user=mysql --basedir=/usr/local/mysql --datadir=/data/mysql

service mysqld start

chkconfig mysqld on

vi /etc/profile

export PATH=$PATH:/usr/local/mysql/bin

source /etc/profile


你可能感兴趣的:(mysql)