1. 安装
1.1 编译环境准备
yum install centos-release-scl -y
yum install devtoolset-4-gcc-c++ devtoolset-4-gcc -y
yum install cmake git -y
yum install ncurses-devel openssl-devel bison autoconf -y
1.2 上传软件包,解压缩
unzip AliSQL-master.zip
#进入目录
cd AliSQL-master.zip
1.3 cmake 配置
在配置前,要先设置下环境变量,这样才能用到 devtoolset-4 套装里的gcc。更多cmake参数。
scl enable devtoolset-4 bash
cmake . \
-DCMAKE_BUILD_TYPE="Release" \
-DCMAKE_INSTALL_PREFIX="/data/server/alisql" \
-DWITH_EMBEDDED_SERVER=0 \
-DWITH_EXTRA_CHARSETS=all \
-DWITH_MYISAM_STORAGE_ENGINE=1 \
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DWITH_PARTITION_STORAGE_ENGINE=1 \
-DWITH_CSV_STORAGE_ENGINE=1 \
-DWITH_ARCHIVE_STORAGE_ENGINE=1 \
-DWITH_BLACKHOLE_STORAGE_ENGINE=1 \
-DWITH_FEDERATED_STORAGE_ENGINE=1 \
-DWITH_PERFSCHEMA_STORAGE_ENGINE=1 \
-DWITH_TOKUDB_STORAGE_ENGINE=1
1.4 编译安装
make -j4 && make install
1.5 添加环境变量
export PATH=/data/server/alisql/bin:$PATH
1.6 Disabling Transparent Hugepages for TokuDB
if test -f /sys/kernel/mm/transparent_hugepage/enabled; then
echo never > /sys/kernel/mm/transparent_hugepage/enabled
fi
if test -f /sys/kernel/mm/transparent_hugepage/defrag; then
echo never > /sys/kernel/mm/transparent_hugepage/defrag
fi
2. 启动
# 添加mysql组+用户
groupadd mysql
useradd -M -s /sbin/nologin -g mysql mysql
mkdir -p /data/alisql
chown -R mysql:mysql /data/alisql
# mysql_install_db设置的datadir必须跟/etc/my.cnf里的datadir相同,
否则报错([ERROR] Fatal error: Can't open and lock privilege tables: Table 'mysql.user' doesn't )
# https://blog.csdn.net/leshami/article/details/41801395
cd /data/server/alisql
scripts/mysql_install_db --user=mysql --datadir=/data/alisql
cp /data/server/alisql/support-files/my-default.cnf /etc/my.cnf
sed -i '/^\[mysqld\]$/{
a\
basedir = /data/server/alisql
a\
datadir = /data/alisql
a\
port = 3306
}' /etc/my.cnf
启动数据库
cp support-files/mysql.server /data/service/mysql
/data/service/mysql start
设置密码
[root@zs alisql]# mysqladmin -u root password
New password:
Confirm new password:
登录数据库
[root@zs alisql]# mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.6.32 Source distribution
Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql>
3. 关闭
mysqladmin -uroot shutdown
Q:初始化mysql数据库提示缺少Data:dumper模块解决方法
解决方法 :安装autoconf库
命令:yum-y install autoconf //此包安装时会安装Data:Dumper模块
Q:MySQL 源码编译安装报错 CMake Error: CMAKE_CXX_COMPILER not set, after EnableLanguage
解决方法 :yum install gcc-c++