centos7.2环境编译安装mysql5.5.48


一.安装cmake编译工具

跨平台编译器
查看是否已经安装了gcc

# rpm -qa | grep gcc

# yum install -y gcc-c++
# yum install -y cmake
# yum install -y git
解决依赖关系
# yum install -y readline-devel zlib-devel openssl-devel

Warning: Bison executable not found in PATH
 
解决方法:
#  yum install -y bison
再次编译即通过

二、编译安装mysql-5.5.48


# tar xf mysql-5.5.48.tar.gz
# cd mysql-5.5.48
# cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_DATADIR=/data/mydata -DSYSCONFDIR=/etc -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_ARCHIVE_STORAGE_ENGINE=1 -DWITH_BLACKHOLE_STORAGE_ENGINE=1 -DWITH_READLINE=1 -DWITH_SSL=system -DWITH_ZLIB=system -DWITH_LIBWRAP=0 -DMYSQL_UNIX_ADDR=/tmp/mysql.sock -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci


# make && make install


编译报错需要删除编译缓存
rm CMakeCache.txt

编译报错:

CMake Error: CMAKE_C_COMPILER not set, after EnableLanguage
CMake Error: Internal CMake error, TryCompile configure of cmake failed
-- Looking for getpagesize - not found
-- Looking for TIOCGWINSZ
CMake Error at /usr/share/cmake/Modules/CMakeCInformation.cmake:37 (get_filename_component):
  get_filename_component called with incorrect number of arguments
Call Stack (most recent call first):
  CMakeLists.txt:3 (PROJECT)

安装gcc-c++即可


cmake . -- Running cmake version 2.8.10.2 -- Could NOT find Git (missing: GIT_EXECUTABLE) -- Configuring with MAX_INDEXES = 64U -- Looking for SHM_HUGETLB -- Looking for SHM_HUGETLB - found -- Looking for sys/types.h -- Looking for sys/types.h - found -- Looking for stdint.h -- Looking for stdint.h - found -- Looking for stddef.h -- Looking for stddef.h - found -- Check size of void * -- Check size of void * - done -- SIZEOF_VOIDP 8 -- MySQL 5.7.9 -- Packaging as: mysql-5.7.9-Linux-x86_64 -- Looked for boost/version.hpp in and -- BOOST_INCLUDE_DIR BOOST_INCLUDE_DIR-NOTFOUND -- LOCAL_BOOST_DIR -- LOCAL_BOOST_ZIP -- Could not find (the correct version of) boost. -- MySQL currently requires boost_1_59_0 CMake Error at cmake/boost.cmake:76 (MESSAGE): You can download it with -DDOWNLOAD_BOOST=1 -DWITH_BOOST= This CMake script will look for boost in . If it is not there, it will download and unpack it (in that directory) for you. If you are inside a firewall, you may need to use an http proxy: export http_proxy=http://example.com:80 Call Stack (most recent call first): cmake/boost.cmake:228 (COULD_NOT_FIND_BOOST) CMakeLists.txt:435 (INCLUDE) -- Configuring incomplete, errors occurred!

安装git即可

三、新建存放Mysql数据库文件的逻辑卷并挂载到/data/mydata下

分区
# fdisk /dev/sda
n
p
3
+20G
w

#挂载系统分区
# kpartx -l /dev/sda
# kpartx -af /dev/sda
# partx -a /dev/sda
验证是否挂载成功
# cat /proc/partitions
创建物理卷
# pvcreate /dev/sda3
创建名为myvg的卷组
# vgcreate myvg /dev/sda3
#创建一个大小为15G,名字叫做mylv的逻辑卷
# lvcreate -L 15G -n mylv myvg
格式化
# mke2fs -t ext4 -b 2048 /dev/myvg/mylv



# mkdir -pv /data/mydata
mkdir: created directory ‘/data’
mkdir: created directory ‘/data/mydata’
# mount /dev/myvg/mylv /data/mydata
# vim /etc/fstab
添加如下内容:
/dev/myvg/mylv /data/mydataext4defaults,noatime 0 0


四、创建Mysql用户

添加mysql用户指定组id和用户id为306
# groupadd -r -g 306 mysql
# useradd -g mysql -r -g 306 -s /sbin/nologin mysql
# id mysql
uid=994(mysql) gid=306(mysql) groups=306(mysql)


改变数据存储目录和安装目录的权限
# cd /usr/local/mysql
添加存放日志的目录
# mkdir /data/binlogs
# chown -R :mysql ./*
# chown -R mysql.mysql /data/mydata

五、启动脚本初始化数据库

# scripts/mysql_install_db --user=mysql --datadir=/data/mydata
# cp support-files/mysql.server /etc/rc.d/init.d/mysqld
# cp support-files/my-large.cnf /etc/my.cnf


编辑/etc/my.cnf配置,加入以下内容

innodb_file_per_table = ON

datadir = /data/mydata

log-bin=/data/binlogs/mysql-bin

注意:

经过实际测试innodb_file_per_table = ON这条参数需要innodb_file_per_table = 1 才能生效,具体可以通过

mysql> show variables like '%per_table%';来查询




把mysqld服务加入到启动项
# chkconfig --add mysqld
# chkconfig --list mysqld


将mysql命令加入环境变量中
vim /etc/profile.d/mysql.sh
加入
export PATH=/usr/local/mysql/bin:$PATH


启动mysqld服务
# service mysqld start
报错
Starting MySQL. ERROR! The server quit without updating PID file (/data/mydata/oadb-test.pid).
# ss -tnl


可以观察日志/data/mydata/oadb-test.err,是日志创建权限的问题
# chown -R mysql.mysql /data

六、上传通达OA数据库并配置相关权限

上传通达OA数据库到服务器上,修改权限,并重启服务,测试


# chown -R mysql.mysql /data/mydata
# service mysqld restart

对mysql数据库用户进行清理,加密码
mysql> use mysql
Database changed
mysql> select user,host,password from user;
+------+-----------+----------+
| user | host      | password |
+------+-----------+----------+
| root | localhost |          |
| root | adb-test  |          |
| root | 127.0.0.1 |          |
| root | ::1       |          |
|      | localhost |          |
|      | adb-test  |          |
+------+-----------+----------+
6 rows in set (0.01 sec)


mysql> delete from user where user='' and host='localhost';
Query OK, 1 row affected (0.01 sec)


mysql> delete from user where user='' and host='adb-test';
Query OK, 1 row affected (0.00 sec)

设置其中root密码为myoa888,并对服务器IP限制
mysql> update user set password=PASSWORD('myoa888'),host='192.168.11.144' where user='root' and host='::1';
Query OK, 1 row affected (0.00 sec)
Rows matched: 1  Changed: 1  Warnings: 0

对root用户加密
mysql> update user set password=PASSWORD('13C1325E831DEC8D60') where user='root' and host in('localhost','adb-test','127.0.0.1');
mysql> select user,host,password from user;
+------+----------------+-------------------------------------------+
| user | host           | password                                  |
+------+----------------+-------------------------------------------+
| root | localhost      | *CF51F9E245F41378E51B4154082F26108A5B0D63 |
| root | adb-test       | *CF51F9E245F41378E51B4154082F26108A5B0D63 |
| root | 127.0.0.1      | *CF51F9E245F41378E51B4154082F26108A5B0D63 |
| root | 192.168.11.144 | *91AF99F23C3D4ED85140D100433725DFA52BECEE |
+------+----------------+-------------------------------------------+

centos7关闭防火墙命令
# systemctl stop firewalld.service

systemctl start firewalld.service#启动firewall
systemctl disable firewalld.service#禁止firewall开机启动
posted @ 2016-03-30 20:59  reblue520  阅读(534)  评论(0编辑  收藏  举报