加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 站长学院 > PHP教程 > 正文

2.LNMP架构-MySQL源码包编译部署详细步骤

发布时间:2020-12-13 21:30:55 所属栏目:PHP教程 来源:网络整理
导读:操作系统:CentOS-7.5-1804 部署组件:Pcre+Zlib+Openssl+Nginx 操作步骤: 一、安装依赖组件 [[email?protected] ~]# yum -y install ncurses ncurses-devel 二、MySQL源码编安装部署 2.1.卸载默认安装MySQL依赖包和Mariadb数据库 [[email?protected] ~]# r

操作系统:CentOS-7.5-1804

部署组件:Pcre+Zlib+Openssl+Nginx

操作步骤:

一、安装依赖组件

[[email?protected] ~]# yum -y install ncurses ncurses-devel

二、MySQL源码编安装部署

2.1.卸载默认安装MySQL依赖包和Mariadb数据库

[[email?protected] ~]# rpm -qa | grep mysql

[[email?protected] ~]# rpm -e --nodeps qt-mysql-4.8.7-2.el7.x86_64

[[email?protected] ~]# rpm -e --nodeps akonadi-mysql-1.9.2-4.el7.x86_64

[[email?protected] ~]# rpm -qa | grep mariadb

[[email?protected] ~]# rpm -e --nodeps mariadb-5.5.60-1.el7_5.x86_64

[[email?protected] ~]# rpm -e --nodeps mariadb-libs-5.5.60-1.el7_5.x86_64

[[email?protected] ~]# rpm -e --nodeps mariadb-server-5.5.60-1.el7_5.x86_64

2.2.安装cmake包

[[email?protected] ~]# cd /usr/local/src/

[[email?protected] src]# tar -xzf cmake-3.14.5.tar.gz -C /usr/local/data/

[[email?protected] src]# cd /usr/local/data/cmake-3.14.5/

[[email?protected] cmake-3.14.5]# ./bootstrap

[[email?protected] cmake-3.14.5]# gmake

[[email?protected] cmake-3.14.5]# make install

[[email?protected] cmake-3.14.5]# echo ‘export PATH=$PATH:/usr/local/data/cmake/bin‘>>/etc/profile

[[email?protected] cmake-3.14.5]# source /etc/profile

[[email?protected] cmake-3.14.5]# cmake --version

3.3.安装boost包

[[email?protected] ~]# cd /usr/local/src/

[[email?protected] src]# tar -zxf boost_1_59_0.tar.gz -C /usr/local/data/

[[email?protected] src]# cd /usr/local/data/

[[email?protected] data]# mv boost_1_59_0/ boost

3.4.创建MySQL用户组和用户

*删除自带MySQL用户*

[[email?protected] ~]# userdel mysql

*删除自带MySQL用户组*

[[email?protected] ~]# groupdel mysql

*创建新的MySQL用户组*

[[email?protected] ~]# groupadd mysql

*创建新的MySQL用户*

[[email?protected] ~]# useradd -r -g mysql mysql

3.5.安装MySQL包
[[email?protected] ~]# cd /usr/local/src/

[[email?protected] src]# tar -xzf mysql-5.7.26.tar.gz -C /usr/local/data/

[[email?protected] src]# cd /usr/local/data/mysql-5.7.26/

[[email?protected] 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

[[email?protected] mysql-5.7.26]# make

[[email?protected] mysql-5.7.26]# make install

3.6.授予配置权限

[[email?protected] mysql-5.7.26]# chown -R mysql:mysql /usr/local/data/mysql

3.7.添加配置文件

[[email?protected] 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

3.8.初始化MySQL

[[email?protected] 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

3.9.配置MySQL环境变量

[[email?protected] mysql-5.7.26]# vim /etc/profile

# Mysql environment
export MYSQL_HOME=/usr/local/data/mysql
export PATH=$PATH:$MYSQL_HOME/bin

[[email?protected] mysql-5.7.26]# source /etc/profile

3.10.设置开机自启

[[email?protected] mysql-5.7.26]# cp /usr/local/data/mysql/support-files/mysql.server /etc/init.d/mysqld

[[email?protected] mysql-5.7.26]# chmod +x /etc/init.d/mysqld

[[email?protected] mysql-5.7.26]# chkconfig --add mysqld

3.11.启动MySQL服务

[[email?protected] mysql-5.7.26]# mysqld_safe --defaults-file=/etc/my.cnf &

3.12.查看MySQL进程

[[email?protected] mysql-5.7.26]# ps -ef | grep mysql

3.13.登陆MySQL数据库

[[email?protected] mysql-5.7.26]# mysql -uroot

3.14.设置登陆密码

*自定义设置密码*

mysql> SET password = password(‘********‘);

3.15.配置远程访问

mysql> UPDATE user SET host = ‘%‘ WHERE user = ‘root‘;

3.16.退出重启MySQL

mysql> exit

[[email?protected] mysql-5.7.26]# /etc/init.d/mysqld restart

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读