操作系统:CentOS_Server_7.5_x64_1804.iso
部署组件:Cmake+Boost+MySQL
操作步骤:
一、安装依赖组件
[root@localhost ~]# yum -y install ncurses ncurses-devel
二、MySQL源码编安装部署
2.1.卸载默认安装MySQL依赖包和Mariadb数据库
[root@localhost ~]# rpm -qa | grep mysql
[root@localhost ~]# rpm -e --nodeps qt-mysql-4.8.7-2.el7.x86_64
[root@localhost ~]# rpm -e --nodeps akonadi-mysql-1.9.2-4.el7.x86_64
[root@localhost ~]# rpm -qa | grep mariadb
[root@localhost ~]# rpm -e --nodeps mariadb-5.5.60-1.el7_5.x86_64
[root@localhost ~]# rpm -e --nodeps mariadb-libs-5.5.60-1.el7_5.x86_64
[root@localhost ~]# rpm -e --nodeps mariadb-server-5.5.60-1.el7_5.x86_64
2.2.安装cmake包
[root@localhost ~]# cd /usr/local/src/
[root@localhost src]# tar -xzf cmake-3.14.5.tar.gz -C /usr/local/data/
[root@localhost src]# cd /usr/local/data/cmake-3.14.5/
[root@localhost cmake-3.14.5]# ./bootstrap
[root@localhost cmake-3.14.5]# gmake
[root@localhost cmake-3.14.5]# make install
[root@localhost cmake-3.14.5]# echo 'export PATH=$PATH:/usr/local/data/cmake/bin'>>/etc/profile
[root@localhost cmake-3.14.5]# source /etc/profile
[root@localhost cmake-3.14.5]# cmake --version
2.3.安装boost包
[root@localhost ~]# cd /usr/local/src/
[root@localhost src]# tar -zxf boost_1_59_0.tar.gz -C /usr/local/data/
[root@localhost src]# cd /usr/local/data/
[root@localhost data]# mv boost_1_59_0/ boost
2.4.创建MySQL用户组和用户
*删除自带MySQL用户*
[root@localhost ~]# userdel mysql
*删除自带MySQL用户组*
[root@localhost ~]# groupdel mysql
*创建新的MySQL用户组*
[root@localhost ~]# groupadd mysql
*创建新的MySQL用户*
[root@localhost ~]# useradd -r -g mysql mysql
2.5.安装MySQL包
[root@localhost ~]# cd /usr/local/src/
[root@localhost src]# tar -xzf mysql-5.7.26.tar.gz -C /usr/local/data/
[root@localhost src]# cd /usr/local/data/mysql-5.7.26/
[root@localhost mysql-5.7.26]#
cmake
-DCMAKE_INSTALL_PREFIX=/usr/local/data/mysql
-DMYSQL_DATADIR=/usr/local/data/mysql/data
-DWITH_BOOST=/usr/local/data/boost
-DSYSCONFDIR=/etc
-DWITH_INNOBASE_STORAGE_ENGINE=1
-DWITH_PARTITION_STORAGE_ENGINE=1
-DWITH_FEDERATED_STORAGE_ENGINE=1
-DWITH_BLACKHOLE_STORAGE_ENGINE=1
-DWITH_MYISAM_STORAGE_ENGINE=1
-DENABLED_LOCAL_INFILE=1
-DENABLE_DTRACE=0
-DDEFAULT_CHARSET=utf8
-DDEFAULT_COLLATION=utf8_general_ci
-DWITH_EMBEDDED_SERVER=1
[root@localhost mysql-5.7.26]# make
[root@localhost mysql-5.7.26]# make install
*授予配置权限*
[root@localhost mysql-5.7.26]# chown -R mysql:mysql /usr/local/data/mysql
*添加配置文件*
[root@localhost mysql-5.7.26]# vim /etc/my.cnf
# For advice on how to change settings please see
# http://dev.mysql.com/doc/refman/5.7/en/server-configuration-defaults.html
# *** DO NOT EDIT THIS FILE. It's a template which will be copied to the
# *** default location during install, and will be replaced if you
# *** upgrade to a newer version of MySQL.
[client]
port=3306
[mysql]
default-character-set=utf8
[mysqld]
port=3306
basedir=/usr/local/data/mysql
datadir=/usr/local/data/mysql/data
character-set-server=utf8
default-storage-engine=InnoDB
max_connections=512
lower_case_table_names=1
query_cache_size=0
tmp_table_size=18M
thread_cache_size=8
myisam_max_sort_file_size=64G
myisam_sort_buffer_size=35M
key_buffer_size=25M
read_buffer_size=64K
read_rnd_buffer_size=256K
sort_buffer_size=256K
innodb_flush_log_at_trx_commit=1
innodb_log_buffer_size=1M
innodb_buffer_pool_size=47M
innodb_log_file_size=24M
innodb_thread_concurrency=8
sql_mode=STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION
*初始化MySQL*
[root@localhost mysql-5.7.26]#
/usr/local/data/mysql/bin/mysqld
--initialize-insecure
--user=mysql
--basedir=/usr/local/data/mysql
--datadir=/usr/local/data/mysql/data
*配置MySQL环境变量*
[root@localhost mysql-5.7.26]# vim /etc/profile
# Mysql environment
export MYSQL_HOME=/usr/local/data/mysql
export PATH=$PATH:$MYSQL_HOME/bin
[root@localhost mysql-5.7.26]# source /etc/profile
*设置开机自启*
[root@localhost mysql-5.7.26]# cp /usr/local/data/mysql/support-files/mysql.server /etc/init.d/mysqld
[root@localhost mysql-5.7.26]# chmod +x /etc/init.d/mysqld
[root@localhost mysql-5.7.26]# chkconfig --add mysqld
[root@localhost mysql-5.7.26]# chkconfig --list
*启动MySQL服务*
[root@localhost mysql-5.7.26]# mysqld_safe --defaults-file=/etc/my.cnf &
*关闭MySQL服务*
[root@localhost mysql-5.7.26]# ps -ef | grep mysql | grep -v grep | awk '{print $2}' | xargs kill -9
*查看MySQL进程*
[root@localhost mysql-5.7.26]# ps -ef | grep mysql
*登陆MySQL数据库*
[root@localhost mysql-5.7.26]# mysql -uroot
*设置登陆密码*
mysql> SET password = password('********');
*配置远程访问*
mysql> GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '********';
mysql> flush privileges;
*退出MySQL*
mysql> exit