centos6.2安装mysql5.5.x

本人经过多次安装,已成功,本人也是从别人那里学习而来的,希望对大家有帮助。


安装cmake工具需安装基础编译环境

使用yum install进行安装
yum -y install ncurses-devel
yum -y install gcc-c++

查看系统是否安装了mysql
yum -qa | grep mysql
如果有,则先删除
yum -e mysql-****(也许删除不了)
或者用强制删除
yum remove -y mysql-****

下载安装软件包:
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


Could NOT find Curses (missing:  CURSES_LIBRARY CURSES_INCLUDE_PATH)
CMake Error at cmake/readline.cmake:83 (MESSAGE):
  Curses library not found.  Please install appropriate package,
报错~!
rm -rf CMakeCache.txt
yum -y install ncurses-deve


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@nagios ~]# /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

你可能感兴趣的:(mysql)