|
前言:MySQL数据库自5.5版本以后,就开始使用CMake编译工具进行安装。
安装环境:
[iyunv@bxw ~]# cat /etc/redhat-release
Red Hat Enterprise Linux Server release 6.5 (Santiago)
[iyunv@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
[iyunv@bxwtools]#Wget
http://wwwNaNake.org/files/v2.8/ ... o-check-certificate //下载cmake源码包
[iyunv@bxwtools]# tar -zxvf cmake-2.8.10.2.tar.gz //解压安装包
[iyunv@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 //安装
[iyunv@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所需要的用户及组
[iyunv@bxw ~]#groupaddmysql
[iyunv@bxw ~]#useradd-r -g mysql mysql
4.安装必要软件包#可配置本地或者互联网yum进行安装
[iyunv@bxw ~]# yum-y install gcc gcc-c++ gcc-g77 autoconfautomake zlib* fiex* libxml* ncurses-devel libmcrypt* libtool-ltdl
5.编译安装mysql#此步骤为cmake方式编译安装mysql
[iyunv@bxw ~]#tar-xf mysql-5.6.14.tar.gz #解压
[iyunv@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安装目录进行授权操作
[iyunv@bxw ~]chmod-R mysql.mysql /application/mysql
7.初始化mysql数据库[iyunv@bxw~]cd /application/mysql/scripts/
[iyunv@bxw~]./mysql_install_db--user=mysql --basedir=/application/mysql --datadir=/application/mysql/data
8.配置mysql启动服务[iyunv@bxw~]cd /application/mysql/support-files/
[iyunv@bxwsupport-files]# cp mysql.server /etc/rc.d/init.d/mysql
[iyunv@bxwsupport-files]# /bin/cp my-default.cnf /etc/my.cnf
[iyunv@bxw~]chkconfig --add mysql
[iyunv@bxw~]chkconfig mysql on
9.启动mysql数据库[iyunv@bxw~]/etc/init.d/mysql start
[iyunv@bxw~]lsof -i:3306
10.修改字符集,防止乱码#添加如下配置内容,服务端字符集需要和客户端保持一致
[iyunv@bxw~]vim /etc/my.cnf
[mysqld]
character-set-server=utf8
[client]
default-character-set=utf8
[mysql]
default-character-set=utf8
[iyunv@bxw~]/etc/init.d/mysql restart
11.将mysql bin加入到环境变量中#加入如下配置代码,也可加入全局环境变量中
[iyunv@bxw~]# cd ~
[iyunv@bxw~]vim .bash_profile
[iyunv@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
[iyunv@bxw~]. .bash_profile
12.设置mysql数据库密码及远程访问权限#mysql数据库初次安装完毕后,默认不需要密码可进行登录
[iyunv@bxw~]# mysql –uroot
mysql>SETPASSWORD FOR 'root'@'localhost' = PASSWORD('123456'); #设置登录密码
mysql>flush privileges;
QueryOK, 0 rows affected (0.00 sec)
[iyunv@bxw~]# mysql –uroot #验证
ERROR1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)
[iyunv@bxw~]# mysql -uroot -p
Enterpassword:
|
|
|
|
|
|
|