首页 > 代码库 > linux下安装mysql(编译mysql源码)
linux下安装mysql(编译mysql源码)
编译所需软件地址
http://mysql.mirror.kangaroot.net/Downloads/ -- 下载需要的mysql版本例如mysql-5.5.39.tar.gz 目前还不太理解mysql那么多的安装包都是干嘛用的,先mark一下。下载的时候注意要下mysql-版本号.tar.gz的包。
http://www.cmake.org/files/v2.8/cmake-2.8.10.2.tar.gz
开始安装
1,安装cmake
1)下载Cmake
[root@test1 software]# wget http://www.cmake.org/files/v2.8/cmake-2.8.3.tar.gz
2)解压
[root@test1 software]# tar -zvxf cmake-2.8.3.tar.gz
3)进入解压后的文件夹
[root@test1 software]# cd cmake-2.8.3
4)生成安装文件
[root@test1 cmake-2.8.3]# ./configure
5)编译
[root@test1 cmake-2.8.3]# make
6)安装
[root@test1 cmake-2.8.3]# make install
2,安装mysql
2,安装mysql
1)下载mysql
[root@test1 software]# wget http://mysql.mirror.kangaroot.net/Downloads/MySQL-5.5/mysql-5.5.39.tar.gz
2)解压
[root@test1 software]# tar -zvxf mysql-5.5.39.tar.gz
3)创建mysql的安装目录及数据库存放目录
[root@test1 software]# mkdir -p /usr/local/mysql //安装mysql
[root@test1 software]# mkdir -p /usr/local/mysql/data //存放数据库
4)创建mysql用户及用户组
[root@test1 software]# groupadd mysql
[root@test1 software]# useradd -r -g mysql mysql
5)进入到mysql的文件夹
[root@test1 software]# cd mysql-5.5.39
6)生成安装文件
[root@test1 mysql-5.5.39]#cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql \
-DMYSQL_UNIX_ADDR=/usr/local/mysql/mysql.sock \
-DDEFAULT_CHARSET=utf8 \
-DDEFAULT_COLLATION=utf8_general_ci \
-DWITH_MYISAM_STORAGE_ENGINE=1 \
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DWITH_MEMORY_STORAGE_ENGINE=1 \
-DWITH_READLINE=1 \
-DENABLED_LOCAL_INFILE=1 \
-DMYSQL_DATADIR=/usr/local/mysql/data \
-DMYSQL_USER=mysql \
-DMYSQL_TCP_PORT=3306
7)编译
[root@test1 mysql-5.5.39]# make
8)安装
[root@test1 mysql-5.5.39]# make install
配置mysql
9)设置mysql目录权限 mysql/mysql
[root@test1 mysql]#cd /usr/local/mysql //把当前目录中所有文件的所有者设为root,所属组为mysql
[root@test1 mysql]# chown -R mysql:mysql /usr/local/mysql
10)将mysql的启动服务添加到系统服务中
[root@test1 mysql]# cp support-files/my-small.cnf /etc/my.cnf
cp: overwrite `/etc/my.cnf‘? y
[root@test1 mysql]# cp support-files/mysql.server /etc/init.d/mysqld
11)创建系统数据库表
[root@test1 mysql]# scripts/mysql_install_db --user=mysql
12)设置系统环境变量
[root@test1 mysql]# vi /root/.bash_profile
[root@test1 mysql]# source /root/.bash_profile
14)启动mysql
[root@test1 mysql]# service mysqld start
Starting MySQL.. SUCCESS!
--------------------------------------------------------------------------------------------------------------
遇到问题
[root@test1 cmake-2.8.3]# ./configure --------------------------------------------- CMake 2.8.3, Copyright 2000-2009 Kitware, Inc. --------------------------------------------- Error when bootstrapping CMake: Cannot find appropriate C compiler on this system. Please specify one using environment variable CC. See cmake_bootstrap.log for compilers attempted. --------------------------------------------- Log of errors: /home/software/cmake-2.8.3/Bootstrap.cmk/cmake_bootstrap.log
缺少C的编译环境
[root@test1 cmake-2.8.3]# yum install gcc
[root@test1 cmake-2.8.3]# ./configure --------------------------------------------- CMake 2.8.3, Copyright 2000-2009 Kitware, Inc. C compiler on this system is: cc --------------------------------------------- Error when bootstrapping CMake: Cannot find appropriate C++ compiler on this system. Please specify one using environment variable CXX. See cmake_bootstrap.log for compilers attempted. --------------------------------------------- Log of errors: /home/software/cmake-2.8.3/Bootstrap.cmk/cmake_bootstrap.log
缺少C++编译器
[root@test1 cmake-2.8.3]# yum install gcc-c++
注:yum安装需要root权限
-------------------------------------------------------------------------------------------------------------------------
在安装了N遍之后终于安装成功了。里面的很多原理还不甚清楚。安装过程中也参考可很多网友的博客,在此一一谢过。
linux下安装mysql(编译mysql源码)