MYSQL5.5源码安装 linux下

时间:2021-12-14 06:15:26
/* 首先安装必要的库 */
yum -y install gcc* ###### 安装 MYSQL ###### 首先安装camke
一、支持YUM,则
yum install -y cmake 二、也可以源码安装
[root@localhost ~]# cd /usr/local/src
#下载cmake
[root@localhost src]# wget http://www.cmake.org/files/v2.8/cmake-2.8.7.tar.gz
[root@localhost src]# tar zxvf cmake-2.8.7.tar.gz
[root@localhost src]# cd cmake-2.8.7
#安装cmake
[root@localhost cmake-2.8.7]# ./configure
[root@localhost cmake-2.8.7]# make
[root@localhost cmake-2.8.7]# make install /* 安装 MYSQL
官网下载 MYSQL5.5版本 linux下源码包
http://dev.mysql.com/downloads/
*/ 安装
[root@localhost ~]# groupadd mysql
[root@localhost ~]# useradd -g mysql mysql
[root@localhost ~]# tar zxvf mysql-5.2.25.tar.gz
[root@localhost ~]# cd mysql-5.2.25 /* #cmake . //默认情况下安装,安装目录为/usr/local/mysql 数据目录为/usr/local/mysql/data
#也可以指定参数安装,如指定UTF8,数据引擎等
#具体参照http://dev.mysql.com/doc/refman/ ... ration-options.html
*/ [root@localhost mysql-5.2.25]# cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_DATADIR=/mysql/data -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DWITH_EXTRA_CHARSETS:STRING=all -DWITH_DEBUG=0 -DWITH_SSL=yes -DWITH_READLINE=1 -DENABLED_LOCAL_INFILE=1
[root@localhost mysql-5.2.25]# make && make install
[root@localhost mysql-5.2.25]# cd /usr/local/mysql
[root@localhost mysql]# chown -R mysql:mysql /usr/local/mysql
[root@localhost mysql]# ./scripts/mysql_install_db --user=mysql -datadir=/mysql/data #此处如不指定datadir,到启动时会报错
[root@localhost mysql]# chown -R root .
[root@localhost mysql]# chown -R mysql data
[root@localhost mysql]# cp support-files/my-medium.cnf /etc/my.cnf
[root@localhost mysql]# ./bin/mysqld_safe --user=mysql & # Next command is optional
[root@localhost mysql]# cp support-files/mysql.server /etc/init.d/mysqld
[root@localhost mysql]# chmod +x /etc/init.d/mysqld
[root@localhost mysql]# /etc/init.d/mysqld start
到此,安装完成

  

此处安装会遇到的错误!!

报错如下:
-- Could NOT find Curses (missing: CURSES_LIBRARY CURSES_INCLUDE_PATH)
CMake Error at cmake/readline.cmake:82 (MESSAGE):
Curses library not found. Please install appropriate package,
remove CMakeCache.txt and rerun cmake.On Debian/Ubuntu, package name is libncurses5-dev, on Redhat and derivates it is ncurses-devel.
Call Stack (most recent call first):
cmake/readline.cmake:126 (FIND_CURSES)
cmake/readline.cmake:216 (MYSQL_USE_BUNDLED_LIBEDIT)
CMakeLists.txt:250 (MYSQL_CHECK_READLINE) --〉
解决方法:
[root@localhost mysql-5.6.1]# rm CMakeCache.txt
[root@localhost mysql-5.6.1]# yum install ncurses-devel
[root@localhost mysql-5.5.11]# yum install bison
接着继续执行编译
#cmake......
#make && make install