CentOS7.5中mysql 5.7.22编译安装的详细步骤

发布时间:2020-06-01 16:30:35 作者:三月
来源:网络 阅读:278

下面讲讲关于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 <<EOF

[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编译安装的详细步骤相关内容,大家还有什么不明白的地方吗?或者想要了解更多相关,可以继续关注我们的行业资讯板块。

推荐阅读:
  1. 编译安装及配置Mysql的详细步骤
  2. mysql5.7编译安装流程简析

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

mysql5.7.22 ce centos7.5

上一篇:一篇文章告诉你大数据的重要性

下一篇:php将json转换成对象或数组

相关阅读

您好,登录后才能下订单哦!

密码登录
登录注册
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》