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

时间:2022-05-29 17:08:39

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

 

   安装环境:

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

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

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

[root@bxwmysql-5.6.14]# cmake --version

-bash: cmake:command not found

[root@bxwtools]#Wget

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

[root@bxwtools]# tar -zxvf cmake-2.8.10.2.tar.gz                             //解压安装包

[root@bxwtools]# cd cmake-2.8.10.2                                           //进入解压目录

[root@bxwcmake-2.8.10.2]# ./bootstrap                                        //执行

[root@bxwcmake-2.8.10.2]# gmake                                              //编译

[root@bxwcmake-2.8.10.2]# gmake install                                      //安装

[root@bxw ~]#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所需要的用户及组

[root@bxw ~]#groupaddmysql

[root@bxw ~]#useradd-r -g mysql mysql

 

4.安装必要软件包

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

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

 

5.编译安装mysql

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

[root@bxw ~]#tar-xf mysql-5.6.14.tar.gz                                          #解压

[root@bxw ~]#cdmysql-5.6.14                                                      #进入解压目录

[root@bxwmysql-5.6.14]# 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   #配置

[root@bxwmysql-5.6.14]# make                                                     #编译            

[root@bxwmysql-5.6.14]# make install                                             #安装

 

 

6.授权mysql安装目录权限

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

[root@bxw ~]chmod-R mysql.mysql /application/mysql

 

 

7.初始化mysql数据库

[root@bxw~]cd /application/mysql/scripts/

[root@bxw~]./mysql_install_db--user=mysql --basedir=/application/mysql --datadir=/application/mysql/data

 

 

8.配置mysql启动服务

[root@bxw~]cd /application/mysql/support-files/

[root@bxwsupport-files]# cp mysql.server /etc/rc.d/init.d/mysql

[root@bxwsupport-files]# /bin/cp my-default.cnf /etc/my.cnf

[root@bxw~]chkconfig --add mysql

[root@bxw~]chkconfig mysql on

 

 

9.启动mysql数据库

[root@bxw~]/etc/init.d/mysql start

[root@bxw~]lsof -i:3306

 

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

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

[root@bxw~]vim /etc/my.cnf

[mysqld]

character-set-server=utf8

[client]

default-character-set=utf8

[mysql]

default-character-set=utf8

[root@bxw~]/etc/init.d/mysql restart

 

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

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

[root@bxw~]# cd ~

[root@bxw~]vim .bash_profile    

[root@bxw~]# 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

[root@bxw~]. .bash_profile

 

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

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

[root@bxw~]# mysql �Curoot

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

mysql>flush privileges;

QueryOK, 0 rows affected (0.00 sec)

[root@bxw~]# mysql �Curoot                                                          #验证

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

[root@bxw~]# mysql -uroot -p

Enterpassword:

 

 

 

 

 

 

 

 

 

 

 

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