mysql 5.5版本需要 cmake进行编译安装
安装cmake工具需安装基础编译环境
下载安装软件包:
mysql-5.5.23.tar.gz
http://dev.mysql.com/get/Downloads/MySQL-5.5/mysql-5.5.23.tar.gz/from/http://mysql.he.net/
cmake-2.8.*.tar.gz
http://www.cmake.org/files/v2.8/cmake-2.8.7.tar.gz
http://down.51cto.com/data/384354#
bison-2.5.tar.gz
http://ftp.gnu.org/gnu/bison/bison-2.5.tar.gz
下载完成
安装cmake
#cd /opt/
#tar zxvf cmake-2.8.5.tar.gz
#cd cmake-2.8.5
#./bootstrap
#gmake && gmake install
#cd ../
#tar zxvf bison-2.5.tar.gz
#cd bison-2.5
#./configure
#make && make install
cmake 安装完毕
编译安装mysql5.5.23
#groupadd mysql
#useradd -s /sbin/nologin -g mysql mysql
#tar zxvf mysql-5.5.23.tar.gz
#cd mysql-5.5.23
#cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_UNIX_ADDR=/tmp/mysql.sock -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DWITH_EXTRA_CHARSETS:STRING=utf8,gbk -DWITH_MYISAM_STORAGE_ENGINE=1 -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_READLINE=1 -DENABLED_LOCAL_INFILE=1 -DMYSQL_DATADIR=/var/mysql/data
#make && make install
#chmod +w /usr/local/mysql/
#chown -R mysql.mysql /usr/local/mysql/
#ln -s /usr/local/mysql/lib/libmysqlclient.so.18 /usr/local/lib/
#mkdir -p /var/mysql
#mkdir -p /var/mysql/data
#mkdir -p /var/mysql/log
#chown -R mysql.mysql /var/mysql/
#cd support-files/
#cp my-large.cnf /var/mysql/my.cnf
#cp mysql.server /etc/init.d/mysqld
初始化mysql
/usr/local/mysql/scripts/mysql_install_db --defaults-file=/var/mysql/my.cnf --basedir=/usr/local/mysql/ --datadir=/var/mysql/data/ --user=mysql
chmod a+x /etc/init.d/mysqld
vi /etc/init.d/mysqld
basedir=/usr/local/mysql
datadir=/var/mysql/data
设置开机启动
chkconfig --add mysqld
chkconfig --level 345 mysqld on
启动mysql
/etc/init.d/mysqld start
Starting MySQL...The server quit without updating PID file (/var/lib/mysql/nagios.pid).
启动失败 原因:
有旧版本的mysql安装 卸载 就版本mysql
修改 /etc/init.d/mysqld
大约214行左右
conf=/var/mysql/my.cnf
默认是 /etc/my.cnf
启动mysql 成功
[root@mysql ~]# /etc/init.d/mysqld start
Starting MySQL. [确定]
[root@mysql ~]# lsof -i:3306
COMMAND PID USER FD TYPE DEVICE SIZE NODE NAME
mysqld 11076 mysql 10u IPv6 157167 TCP *:mysql (LISTEN)
添加环境变量:
#vi /etc/profile
……
PATH=$PATH:/usr/local/mysql/bin
#source /etc/profile
#mysql 登陆mysql (默认密码为空)
mysql>