CentOS7.5中mysql5.7.22编译安装的详细步骤

下面讲讲关于CentOS7.5中MySQL 5.7.22编译安装的详细步骤,文字的奥妙在于贴近主题相关。所以,闲话就不谈了,我们直接看下文吧,相信看完CentOS7.5中mysql 5.7.22编译安装的详细步骤这篇文章你一定会有所受益。

创新互联建站服务项目包括南山网站建设、南山网站制作、南山网页制作以及南山网络营销策划等。多年来,我们专注于互联网行业,利用自身积累的技术优势、行业经验、深度合作伙伴关系等,向广大中小型企业、政府机构等提供互联网行业的解决方案,南山网站推广取得了明显的社会效益与经济效益。目前,我们服务的客户以成都为中心已经辐射到南山省份的部分城市,未来相信会继续扩大服务区域并继续获得客户的支持与信任!

1 mysql安装配置

在db01上操作

1.1 卸载自带的mariadb相关软件包

# rpm -qa|grep mariadb

mariadb-libs-5.5.56-2.el7.x86_64

# rpm -e mariadb-libs-5.5.56-2.el7.x86_64 --nodeps

# yum install libaio-devel ncurses-devel cmake gcc gcc-c++ bison -y 

1.2 创建相关目录

mkdir -p /usr/local/mysql/tmp -p 

mkdir -p /usr/local/mysql/log -p

mkdir /usr/local/mysql/mysql_log-bin/ -p  #指定binlog日志存放路径

useradd -s /sbin/nologin -M mysql

cd /server/tools/

解压mysql-boost-5.7.22.tar.gz包,该包里包含了boost包和mysql包,从MySQL 5.7.5开始Boost库是必需的

# tar xf mysql-boost-5.7.22.tar.gz

1.3 编译安装

# cd mysql-5.7.22/

cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mysql/ \

-DMYSQL_DATADIR=/usr/local/mysql/data \

-DDOWNLOAD_BOOST=1 \

-DWITH_BOOST=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 \

-DWITH_EMBEDDED_SERVER=1

# make

# make install

# echo "export PATH=$PATH:/usr/local/mysql/bin/" >>/etc/profile

# source /etc/profile

1.4 拷贝启动脚本,设为开机自启动

# cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld

# chmod +x /etc/init.d/mysqld 

# chkconfig --add mysqld

# chkconfig mysqld on

1.5 创建mysql配置文件

cat >/etc/my.cnf <

[mysqld]

basedir = /usr/local/mysql/

datadir = /usr/local/mysql/data/

tmpdir = /usr/local/mysql/tmp/

pid-file = /usr/local/mysql/data/my.pid

port = 3306

default_storage_engine = InnoDB

innodb_autoinc_lock_mode = 2

explicit_defaults_for_timestamp = true

character-set-client-handshake = FALSE

character_set_server = utf8

skip-name-resolve

max_connections=1000

max_connect_errors = 1000000

max_allowed_packet = 1G

connect_timeout = 3600

wait_timeout = 3600

interactive_timeout = 3600

innodb_lock_wait_timeout = 10

slave-skip-errors  = 1032,1062

log-error = /usr/local/mysql/log/error.log

slow_query_log = on

slow_query_log_file = /usr/local/mysql/log/slow-query-log.log

long_query_time = 1

log-queries-not-using-indexes

log-slow-admin-statements

log-slow-slave-statements

server-id = 100

log-bin = /usr/local/mysql/mysql_log-bin/log-bin  #指定binlog日志存放路径

binlog-format = ROW

EOF

1.6 初始化数据库

之前版本mysql_install_db是在mysql_basedir/script下,5.7放在了mysql_install_db/bin目录下,且已被废弃

"--initialize"会生成一个随机密码(~/.mysql_secret),而"--initialize-insecure"不会生成密码

--datadir目标目录下不能有数据文件

# chown -R mysql.mysql /usr/local/mysql/

# mysqld --initialize-insecure --user=mysql --basedir=/usr/local/mysql/ --datadir=/usr/local/mysql/data

# mysqld_safe --defaults-file=/etc/my.cnf &   #启动mysql服务

# /etc/init.d/mysqld start                  #启动mysql服务,同上条命令一样

# mysql   #登录mysql,没有密码

# mysqladmin -uroot password  sjk2018zpkj  #设置root密码为sjk2018

# mysql -uroot -psjk2018zpkj -e "grant all on *.* to root@'172.17.53.%' identified by 'sjk2018zpkj';"

mysql> create user test@'172.17.53.%' identified by 'pt2017';

mysql> flush privileges;

对于以上CentOS7.5中mysql 5.7.22编译安装的详细步骤相关内容,大家还有什么不明白的地方吗?或者想要了解更多相关,可以继续关注我们的行业资讯板块。


标题名称:CentOS7.5中mysql5.7.22编译安装的详细步骤
URL链接:http://scyanting.com/article/gspsie.html