linux下cmake方式编译安装MySQL数据库

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了linux下cmake方式编译安装MySQL数据库相关的知识,希望对你有一定的参考价值。

前言:mysql数据库自5.5版本以后,就开始使用CMake编译工具进行安装。

 

   安装环境:

[[email protected] ~]# cat /etc/redhat-release 
Red Hat Enterprise Linux Server release 6.5 (Santiago)
[[email protected] ~]# mysqladmin --version
mysqladmin  Ver 8.42 Distrib 5.6.14, for Linux on x86_64

1.安装cmake源码包(已安装则略过此步)

#如果系统中无cmake命令,则需要下载cmake安装包并进行安装

[[email protected]]# cmake --version

-bash: cmake:command not found

[[email protected]]#Wget

http://wwwNaNake.org/files/v2.8/cmake-2.8.10.2.tar.gz--no-check-certificate  //下载cmake源码包

[[email protected]]# tar -zxvf cmake-2.8.10.2.tar.gz                             //解压安装包

[[email protected]]# cd cmake-2.8.10.2                                           //进入解压目录

[[email protected]]# ./bootstrap                                        //执行

[[email protected]]# gmake                                              //编译

[[email protected]]# gmake install                                      //安装

[[email protected] ~]#cmake --version                                                 //验证安装

cmake version2.8.10.2

 

2.下载mysql安装介质

#可到mysql网站进行下载相关版本并上传至服务器

http://www.mysql.com/

http://download.csdn.net/detail/sunny_sailor/8072429

 

3.创建mysql用户及组

#创建安装mysql所需要的用户及组

[[email protected] ~]#groupaddmysql

[[email protected] ~]#useradd-r -g mysql mysql

 

4.安装必要软件包

#可配置本地或者互联网yum进行安装

[[email protected] ~]# yum-y install  gcc gcc-c++ gcc-g77 autoconfautomake zlib* fiex* libxml* ncurses-devel libmcrypt* libtool-ltdl

 

5.编译安装mysql

#此步骤为cmake方式编译安装mysql

[[email protected] ~]#tar-xf mysql-5.6.14.tar.gz                                          #解压

[[email protected] ~]#cdmysql-5.6.14                                                      #进入解压目录

[[email protected]]# cmake . -DCMAKE_INSTALL_PREFIX=/application/mysql-DMYSQL_DATADIR=/application/mysql/data -DSYSCONFDIR=/etc/mysql-DWITH_MYISAM_STORAGE_ENGINE=1 -DWITH_INNOBASE_STORAGE_ENGINE=1-DWITH_MEMORY_STORAGE_ENGINE=1 -DWITH_READLINE=1-DMYSQL_UNIX_ADDR=/var/lib/mysql/mysql.sock -DMYSQL_TCP_PORT=3306-DWITH_PARTITION_STORAGE_ENGINE=1 -DEXTRA_CHARSETS=all -DDEFAULT_CHARSET=utf8-DDEFAULT_COLLATION=utf8_general_ci   #配置

[[email protected]]# make                                                     #编译            

[[email protected]]# make install                                             #安装

 

 

6.授权mysql安装目录权限

#mysql安装目录进行授权操作

[[email protected] ~]chmod-R mysql.mysql /application/mysql

 

 

7.初始化mysql数据库

[[email protected]~]cd /application/mysql/scripts/

[[email protected]~]./mysql_install_db--user=mysql --basedir=/application/mysql --datadir=/application/mysql/data

 

 

8.配置mysql启动服务

[[email protected]~]cd /application/mysql/support-files/

[[email protected]]# cp mysql.server /etc/rc.d/init.d/mysql

[[email protected]]# /bin/cp my-default.cnf /etc/my.cnf

[[email protected]~]chkconfig --add mysql

[[email protected]~]chkconfig mysql on

 

 

9.启动mysql数据库

[[email protected]~]/etc/init.d/mysql start

[[email protected]~]lsof -i:3306

 

10.修改字符集,防止乱码

#添加如下配置内容,服务端字符集需要和客户端保持一致

[[email protected]~]vim /etc/my.cnf

[mysqld]

character-set-server=utf8

[client]

default-character-set=utf8

[mysql]

default-character-set=utf8

[[email protected]~]/etc/init.d/mysql restart

 

11.mysql bin加入到环境变量中

#加入如下配置代码,也可加入全局环境变量中

[[email protected]~]# cd ~

[[email protected]~]vim .bash_profile    

[[email protected]~]# cat .bash_profile

#.bash_profile

 

#Get the aliases and functions

if[ -f ~/.bashrc ]; then

        . ~/.bashrc

fi

 

#User specific environment and startup programs

PATH=$PATH:$HOME/bin

PATH=/application/mysql/bin:$PATH

exportPATH

[[email protected]~]. .bash_profile

 

12.设置mysql数据库密码及远程访问权限

#mysql数据库初次安装完毕后,默认不需要密码可进行登录

[[email protected]~]# mysql –uroot

mysql>SETPASSWORD FOR ‘root‘@‘localhost‘ = PASSWORD(‘123456‘);                      #设置登录密码

mysql>flush privileges;

QueryOK, 0 rows affected (0.00 sec)

[[email protected]~]# mysql –uroot                                                          #验证

ERROR1045 (28000): Access denied for user ‘root‘@‘localhost‘ (using password: NO)

[[email protected]~]# mysql -uroot -p

Enterpassword:

 

 

 

 

 

 

 

 

 

 

 

本文出自 “笑傲&風雲” 博客,请务必保留此出处http://6197435.blog.51cto.com/6187435/1866866

以上是关于linux下cmake方式编译安装MySQL数据库的主要内容,如果未能解决你的问题,请参考以下文章

linux下采用cmake或gmake方式编译安装mysql

linux下源码编译安装mysql详解

linux下cmake编译安装配置和卸载mysql

linux下mysql的安装配置

CentOS6.7下使用cmake编译安装MySQL5.5.32笔记

Linux(CentOS或RadHat)下MySQL源码安装